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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « CHANGELOG.md ('k') | pkg/js/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 Methods and annotations to specify interoperability with JavaScript APIs. 1 Methods and annotations to specify interoperability with JavaScript APIs.
2 2
3 *Note: This package is beta software.* 3 *Note: This package is beta software.*
4 4
5 *Note: This packages requires Dart SDK `>=1.13.0-dev.7`.* 5 *Note: This packages requires Dart SDK `>=1.13.0-dev.7`.*
6 6
7 ### Adding the dependency 7 ### Adding the dependency
8 8
9 Add the following to your `pubspec.yaml`: 9 Add the following to your `pubspec.yaml`:
10 10
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // 50 //
51 // We recommend against using custom JavaScript names whenever 51 // We recommend against using custom JavaScript names whenever
52 // possible. It is easier for users if the JavaScript names and Dart names 52 // possible. It is easier for users if the JavaScript names and Dart names
53 // are consistent. 53 // are consistent.
54 @Js("LatLng") 54 @Js("LatLng")
55 class Location { 55 class Location {
56 external Location(num lat, num lng); 56 external Location(num lat, num lng);
57 } 57 }
58 ``` 58 ```
59 59
60 #### Maps 60 #### JavaScript object literals
61 61
62 Dart `Map` objects, including literals, are "opaque" in JavaScript. 62 Many JavaScript APIs take an object literal as an argument. For example:
63 You must create Dart classes for each of these.
64
65 ```js 63 ```js
66 // JavaScript 64 // JavaScript
67 printOptions({responsive: true}); 65 printOptions({responsive: true});
68 ``` 66 ```
69 67
68 If you want to use `printOptions` from Dart, you cannot simply pass a Dart `Map`
69 object – they are are "opaque" in JavaScript.
70
71
72 Instead, create a Dart class with both the `@JS()` and
73 `@anonymous` annotations.
74
70 ```dart 75 ```dart
71 // Dart 76 // Dart
72 void main() { 77 void main() {
73 printOptions(new Options(responsive: true)); 78 printOptions(new Options(responsive: true));
74 } 79 }
75 80
76 @Js() 81 @Js()
Jacob 2015/11/11 20:14:21 while you are fixing this, change @Js to @JS
77 external printOptions(Options options); 82 external printOptions(Options options);
78 83
79 @Js() 84 @Js()
85 @anonymous
80 class Options { 86 class Options {
81 external bool get responsive; 87 external bool get responsive;
82 88
83 external factory Options({bool responsive}); 89 external factory Options({bool responsive});
84 } 90 }
85 ``` 91 ```
86 92
87 ## Contributing and Filing Bugs 93 ## Contributing and Filing Bugs
88 94
89 Please file bugs and features requests on the [Github issue tracker](https://git hub.com/dart-lang/js-interop/issues). 95 Please file bugs and features requests on the [Github issue tracker](https://git hub.com/dart-lang/sdk/issues).
90 96
91 We also love and accept community contributions, from API suggestions to pull re quests. 97 We also love and accept community contributions, from API suggestions to pull re quests.
92 Please file an issue before beginning work so we can discuss the design and impl ementation. 98 Please file an issue before beginning work so we can discuss the design and impl ementation.
93 We are trying to create issues for all current and future work, so if something there intrigues you (or you need it!) join in on the discussion. 99 We are trying to create issues for all current and future work, so if something there intrigues you (or you need it!) join in on the discussion.
94 100
95 Code contributors must sign the 101 Code contributors must sign the
96 [Google Individual Contributor License Agreement](https://developers.google.com/ open-source/cla/individual?csw=1). 102 [Google Individual Contributor License Agreement](https://developers.google.com/ open-source/cla/individual?csw=1).
OLDNEW
« 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