I am using Pase.com with js SDK for the backend of my Dart App. This works fine apart from the parse sdk accepts an object of callback functions. In dart Im unsure how to do this, I can get single callbacks working fine. But Im completely lost here.
Normal Parse JS for registering a user
var user = new Parse.User();
user.set("username", "my name");
user.set("password", "my pass");
user.set("email", "[email protected]");
// other fields can be set just like with Parse.Object
user.set("phone", "415-392-0202");
user.signUp(null, {
success: function(user) {
// Hooray! Let them use the app now.
},
error: function(user, error) {
// Show the error message somewhere and let the user try again.
alert("Error: " + error.code + " " + error.message);
}
});
My Dart code
void registerSuccess(user) {
print("success");
}
void registerFailed(user, error){
print("fail");
}
void register(String email, String password)
{
js.scoped(() {
var parse = js.context.Parse;
var parseUser = new js.Proxy(parse.User);
parseUser.set("username", "my name");
parseUser.set("password", "my pass");
parseUser.set("email", "[email protected]");
print(parseUser.getEmail());
var callbackSuccess = new js.Callback.once(() => registerSuccess());
var callbackFailed = new js.Callback.once(() => registerFailed());
parseUser.signUp(null,{"success":callbackSuccess, "error": callbackFailed});
//parseUser.signUp();
});
}
Also the callback function needs accept vars passed back from the js.
Any help would be a appreciated, I have be spinning my wheels for 2 days on this.