Reputation: 616
Given that Dart will need to inter-operate with other javascript frameworks. In the client-web environment what are the current or intended best-practices to communicate with a Dart program from javascript?
Upvotes: 4
Views: 428
Reputation: 1827
Sample code:
import 'package:js/js.dart' as js;
js.context.jQuery();
var context = js.context;
var param = js.map({ 'modal': true, "width":1000, "height":600});
js.context.jQuery("#dialog").dialog(param);
in html
<script src="packages/browser/interop.js"></script>
The above code open a div as dialog using jQuery.
Upvotes: 1
Reputation: 20865
Currently you need to use window.postMessage to communicate with Dart however a interorp layer is planned and should arrive in dart2js any day now (although I believe that its initial incarnation will focus more Dart->JavaScript than JavaScript->Dart).
Upvotes: 3