Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a good way to create a dart wrapper for a Javascript API?

Tags:

dart

dart2js

suppose I want to create a wrapper for a javascript API such as localStorage that adds some additional functionality like automatically journaling changes and syncing it to a server. Dart already has wrappers for these APIs, what is a good way to create a dart wrapper for my wrapped API?

like image 544
jz87 Avatar asked May 26 '13 09:05

jz87


People also ask

Is Dart written in JavaScript?

To run in mainstream web browsers, Dart relies on a source-to-source compiler to JavaScript.

Can Dart use JavaScript libraries?

This library provides access to JavaScript objects from Dart, allowing Dart code to get and set properties, and call methods of JavaScript objects and invoke JavaScript functions. The library takes care of converting between Dart and JavaScript objects where possible, or providing proxies if conversion isn't possible.


1 Answers

You can use the Proxy class for this. There is a good article explaining how this works at http://www.dartlang.org/articles/js-dart-interop/

like image 167
Christophe Herreman Avatar answered Nov 09 '22 07:11

Christophe Herreman