Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// A [Resource] is data that can be read into a Dart program. | 5 /// A [Resource] is data that can be read into a Dart program. |
| 6 /// | 6 /// |
| 7 /// A resource is identified by a URI. It can be loaded as bytes or data. | 7 /// A resource is identified by a URI. It can be loaded as bytes or data. |
| 8 /// The resource URI may be a `package:` URI. | 8 /// The resource URI may be a `package:` URI. |
| 9 /// | 9 /// |
| 10 /// Example: | 10 /// Example: |
| 11 /// | 11 /// |
| 12 /// var resource = new Resource("package:foo/foo_data.txt"); | 12 /// var resource = new Resource("package:foo/foo_data.txt"); |
| 13 /// var string = await resource.readAsString(UTF8); | 13 /// var string = await resource.readAsString(UTF8); |
| 14 /// print(string); | 14 /// print(string); |
| 15 /// | 15 /// |
| 16 /// Example: | 16 /// Example: |
| 17 /// | 17 /// |
| 18 /// var resource = new Resource("http://example.com/data.json"); | 18 /// var resource = new Resource("http://example.com/data.json"); |
| 19 /// var obj = await resource.openRead() // Reads as stream of bytes. | 19 /// var obj = await resource.openRead() // Reads as stream of bytes. |
| 20 /// .transform(UTF8.fuse(JSON).decoder) | 20 /// .transform(UTF8.fuse(JSON).decoder) |
| 21 /// .first; | 21 /// .first; |
| 22 /// | 22 /// |
| 23 /// | 23 /// |
| 24 /// Notice: Currently this package requires `dart:io` to do the reading, | 24 /// Notice: Currently this library requires `dart:io` to do the reading, |
| 25 /// so it doesn't work in the browser. | 25 /// so it doesn't work in the browser. |
|
floitsch
2016/01/21 12:53:57
Mention browser_resource here.
Lasse Reichstein Nielsen
2016/01/25 10:48:37
Done.
| |
| 26 library resource; | 26 library resource; |
| 27 | 27 |
| 28 export "src/resource.dart" show Resource; | 28 export "src/resource.dart"; |
| 29 export "src/loader.dart" show ResourceLoader; | 29 export "src/loader.dart"; |
| OLD | NEW |