Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(895)

Unified Diff: lib/resource.dart

Issue 1606473002: Add examples to resource package. (Closed) Base URL: https://github.com/dart-lang/resource.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/resource.dart
diff --git a/lib/resource.dart b/lib/resource.dart
index b23d220637065e1ddbbcf0283b3c1f50c03a4ad1..83c75c695dabd9249317861ec15cbf8691c36cb8 100644
--- a/lib/resource.dart
+++ b/lib/resource.dart
@@ -2,9 +2,27 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-/// A [Resource] is data that can be loaded into a Dart program.
+/// A [Resource] is data that can be read into a Dart program.
///
-/// A resource is identified by a URI.
+/// A resource is identified by a URI. It can be loaded as bytes or data.
+/// The resource URI may be a `package:` URI.
+///
+/// Example:
+///
+/// var resource = new Resource("package:foo/foo_data.txt");
+/// var string = await resource.readAsString(UTF8);
+/// print(string);
+///
+/// Example:
+///
+/// var resource = new Resource("http://example.com/data.json");
+/// var obj = await resource.openRead() // Reads as stream of bytes.
+/// .transform(UTF8.fuse(JSON).decoder)
+/// .first;
+///
+///
+/// Notice: Currently this package requires `dart:io` to do the reading,
+/// so it doesn't work in the browser.
library resource;
export "src/resource.dart" show Resource;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698