dart - Problems with JS Interop when compiled to javascript -
i'm using parse.com server solution. i'm loading framework.js in dart.html header section.
first of all, everything(crud) works great running in dartium. goal make work compiled javascript well.
first thing need make login work. parse js initialization , logging in follow:
parse.initialize("appid", "appkey"); parse.user.login("myname", "mypass", { success: function(user) { // stuff after successful login. }, error: function(user, error) { // login failed. check error see why. } });
and here updated attempt in dart. i'm not running minified option.
import 'dart:html'; import 'package:web_ui/web_ui.dart'; import 'package:js/js.dart' js; void main() { js.context.parse.initialize("appid", "appkey"); js.context.parse.user.login("myname","mypass", js.map({ "success": new js.callback.once((user){ print("success"); }), "error": new js.callback.once((user, error){ print("error"); }), })); }
it's working great in dartium , prints "success".
when compiled javascript error in safari: json.stringify cannot serialize cyclic structures.
the full error in google chrome console looks this:
uncaught typeerror: converting circular structure json js.dart:1043
$.proxy__forward js.dart:1043
$$.proxy.nosuchmethod$1 js.dart:1033 (anonymous function)
$.main tabort.dart:21
$.main0 tabort.html_bootstrap.dart:8
$$._isolatecontext.eval$1 isolate_helper.dart:265
$.startrootisolate isolate_helper.dart:89 (anonymous function)
tabort.html_bootstrap.dart.js:13949
help, or pointing me in right direction appreciated!
edit: downloaded latest continuous build: 0.1.2_r22610. now works!
the dart code corresponding js code :
parse.user.login("myname", "mypass", { success: function(user) { // stuff after successful login. }, error: function(user, error) { // login failed. check error see why. } });
is :
js.context.parse.user.login("myname", "mypass", js.map({ 'success': new js.callback.once((user) { // stuff after successful login. }), 'error': new js.callback.once((user, error) { // login failed. check error see why. }) }));
if compile dart code js don't use --minify option because of issue 9283.
edit : problem ( json.stringify cannot serialize cyclic structures ) should disappear starting r22598 (see https://groups.google.com/a/dartlang.org/d/msg/misc/zz8sx5rojis/uddcmmnaytkj)
Comments
Post a Comment