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

Unified Diff: pkg/js/README.md

Issue 1438003002: pkg/js: fix readme for pkg/js and prepare another release (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: oops Created 5 years, 1 month 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 | « CHANGELOG.md ('k') | pkg/js/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/js/README.md
diff --git a/pkg/js/README.md b/pkg/js/README.md
index e28092384b4fb89bd61abf9ec474993b06c3314a..ff9501b1abb66dc3457b61869ade4a8338c75885 100644
--- a/pkg/js/README.md
+++ b/pkg/js/README.md
@@ -26,21 +26,21 @@ There is a [full example](https://github.com/dart-lang/sdk/tree/master/pkg/js/ex
```dart
// Calls invoke JavaScript `JSON.stringify(obj)`.
-@Js("JSON.stringify")
+@JS("JSON.stringify")
external String stringify(obj);
```
#### Classes and Namespaces
```dart
-@Js('google.maps')
+@JS('google.maps')
library maps;
// Invokes the JavaScript getter `google.maps.map`.
external Map get map;
// `new Map` invokes JavaScript `new google.maps.Map(location)`
-@Js()
+@JS()
class Map {
external Map(Location location);
external Location getLocation();
@@ -51,32 +51,38 @@ class Map {
// We recommend against using custom JavaScript names whenever
// possible. It is easier for users if the JavaScript names and Dart names
// are consistent.
-@Js("LatLng")
+@JS("LatLng")
class Location {
external Location(num lat, num lng);
}
```
-#### Maps
-
-Dart `Map` objects, including literals, are "opaque" in JavaScript.
-You must create Dart classes for each of these.
+#### JavaScript object literals
+Many JavaScript APIs take an object literal as an argument. For example:
```js
// JavaScript
printOptions({responsive: true});
```
+If you want to use `printOptions` from Dart, you cannot simply pass a Dart `Map`
+object – they are are "opaque" in JavaScript.
+
+
+Instead, create a Dart class with both the `@JS()` and
+`@anonymous` annotations.
+
```dart
// Dart
void main() {
printOptions(new Options(responsive: true));
}
-@Js()
+@JS()
external printOptions(Options options);
-@Js()
+@JS()
+@anonymous
class Options {
external bool get responsive;
@@ -86,7 +92,7 @@ class Options {
## Contributing and Filing Bugs
-Please file bugs and features requests on the [Github issue tracker](https://github.com/dart-lang/js-interop/issues).
+Please file bugs and features requests on the [Github issue tracker](https://github.com/dart-lang/sdk/issues).
We also love and accept community contributions, from API suggestions to pull requests.
Please file an issue before beginning work so we can discuss the design and implementation.
« no previous file with comments | « CHANGELOG.md ('k') | pkg/js/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698