Created
May 17, 2017 17:33
-
-
Save Ticore/58128c76f5fa772dc6fd6d721fc63221 to your computer and use it in GitHub Desktop.
Dart JS Interop Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:js/js.dart'; | |
| void main() { | |
| int count = 10000; | |
| var startTime = new DateTime.now(); | |
| var jsonStrList = []; | |
| for (int i = 0; i < count; ++i) { | |
| jsonStrList.add(testJSInterop()); | |
| } | |
| var endTime = new DateTime.now(); | |
| print('${endTime.difference(startTime).inMilliseconds / count} ms/js call'); | |
| } | |
| @JS("JSON.stringify") | |
| external String stringify(obj); | |
| String testJSInterop() { | |
| return stringify({'time': new DateTime.now()}); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <body> | |
| <script type="application/dart" src="js_interop_test.dart"></script> | |
| <script src="packages/browser/dart.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: js_interop | |
| description: A sample web application | |
| dependencies: | |
| browser: any | |
| js: any | |
| dart_to_js_script_rewriter: ^1.0.1 | |
| transformers: | |
| - dart_to_js_script_rewriter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment