After you call allowInterop on a Dart function, you have a JavaScript
function that can be used anywhere a JavaScript function would be used.
Example:
import 'package:js/js.dart';
@Js()
set onload(Function callback);
void exampleListener(Event e) {
print("Event $e");
}
void main() {
onload = allowInterop(exampleListener);
}
If you want to pass Dart functions to JavaScript you must first call:
allowInterop(yourDartFunction)
which will create a JavaScript function from your Dart function. The
JavaScript function can then be invoked from either Dart or JavaScript with
minimal limitations.
Limitations:
1. You cannot pass named arguments to the function.
2. Dart zones support is unspecified if the function is called
asynchronously from JavaScript.
Both of these limitations may be lifted in the future. For example, if
Dart2Js were to support zones via a JavaScript polyfill script similar to
how Angular supports zones, you could still get full zone support while
using JavasScript interop.
Post by Don OlmsteadWhat would a function end up looking like? Like setting window.onload
without using addEventListener?
Post by Filipe MorgadoLooks awesome :)
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.