Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return promise in modelActions.validate #16

Open
naomiajacobs opened this issue Nov 4, 2016 · 3 comments
Open

Return promise in modelActions.validate #16

naomiajacobs opened this issue Nov 4, 2016 · 3 comments

Comments

@naomiajacobs
Copy link
Contributor

So that it matches the signature of the others?

@juanca
Copy link
Contributor

juanca commented Nov 9, 2016

Yeah, and we can potentially drop preValidateAction and postValidateAction since async actions should really be promises which can be chained (on usages): flexibility! modularity!

E.g.

 modelActions.validate('some_collection', attributes, {
    preValidateAction: someActionBeforeValidation,
    postValidateAction: someComplexActionThatActuallyDoesManyThings
});

vs

dispatch(someActionBeforeValidation);
modelActions.validate('some_collection', attributes)
  .done(someSuccessAction)
  .fail(someFailureAction)
  .always(someCleanupAction);

@juanca
Copy link
Contributor

juanca commented Nov 9, 2016

And with promises, done callbacks can be broken up since it can queue up many functions!

@juanca
Copy link
Contributor

juanca commented Nov 9, 2016

This is related to #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants