var UserQueries = Marty.createQueries({
getUser: function (id) {
this.dispatch(UserActions.RECEIVE_USER_STARTING, id);
this.app.userAPI.getUser(id).then(function (res) {
if (res.status === 200) {
this.dispatch(UserActions.RECEIVE_USER, res.body, id);
} else {
this.dispatch(UserActions.RECEIVE_USER_FAILED, id);
}
}.bind(this)).catch(function (err) {
this.dispatch(UserActions.RECEIVE_USER_FAILED, id, err);
}.bind(this))
}
});class UserQueries extends Marty.Queries {
getUser(id) {
this.dispatch(UserActions.RECEIVE_USER_STARTING, id);
this.app.userAPI.getUser(id).then((res) => {
if (res.status === 200) {
this.dispatch(UserActions.RECEIVE_USER, res.body, id);
} else {
this.dispatch(UserActions.RECEIVE_USER_FAILED, id);
}
}).catch((err) => this.dispatch(UserActions.RECEIVE_USER_FAILED, id, err));
}
}dispatch(type, [...])
Dispatches an action payload with the given type. Any action handlers will be invoked with the given action handlers.
app
Returns the instance's application.