Skip to content

libraries for Dart and JavaScript to break the Dart<->JavaScript language barrier

License

Notifications You must be signed in to change notification settings

joinmytalk/dartxjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dartxjs

dartxjs consists of libraries for Dart and JavaScript that allow programmers to write browser-based applications in both Dart and JavaScript by providing a mechanism to send message from Dart to JavaScript and vice versa.

Installation

To install the Dart library, create a pubspec.yaml with the following content:

dependencies:
  dartxjs:
    git: git:https://github.com/joinmytalk/dartxjs.git

Then run $DART_SDK/bin/pub install dartxjs.

To install the JavaScript library, simply copy dartxjs.js from the packages/dartxjs directory created by pub to wherever you need it and include it like you would do with any other JavaScript library. There is also a minified version, named dartxjs.min.js available.

Usage

After you have installed dartxjs, include it in your Dart application like this:

#import('package:dartxjs/dartxjs.dart');

You can now send and receive messages in Dart like this:

DartToJSCommunicator comm = new DartToJSCommunicator();
comm.receiveMessage = (m) => print('Hello ${m["msg“]}');
comm.sendMessage({"msg":"JavaScript"});

And on the JavaScript side:

JSToDartCommunicator.receiveMessage(function(m) {
	console.log("Hello " + m.msg);
});
JSToDartCommunicator.sendMessage({"msg":"Dart"});

License

See the file LICENSE for license information.

Author

Andreas Krennmair [email protected]

About

libraries for Dart and JavaScript to break the Dart<->JavaScript language barrier

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published