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

Persist changes in postValidate and preSave hooks to database [#43] #85

Merged
merged 1 commit into from
Nov 4, 2016
Merged

Conversation

caseyWebb
Copy link
Contributor

@caseyWebb caseyWebb commented Nov 2, 2016

Changes made in postValidate and preSave hooks were not being persisted; now they are 🎉

Also FWIW, besides semantics, there seems to me to be no noticeable between the two hooks.

This...

  // ...
  return Promise.all(that._getHookPromises('postValidate'));
}).then(function() {
  return Promise.all(that._getHookPromises('preSave'));
}).then(function() {
  // ...

could be changed to something like...

return Promise.all(_.compose(_.flatten, _.map)(['postValidate', 'preSave'], function(hookName) {
  return that._getHookPromises(hookName);
}))

...which isn't all that great, but can turn into this...

return Promise.all(_.flatMap(['postValidate', 'preSave'], (h) => this._getHookPromises(h)))

arrow funcs <3 fp & promises, their lack of lexical binding prevents the need for var that = this in nearly every case

[x-ref #43]

@scottwrobinson
Copy link
Owner

Looks good from what I can tell. Should have time to get to this tonight or tomorrow morning. Thanks for the PR!

@scottwrobinson scottwrobinson merged commit d92eef3 into scottwrobinson:master Nov 4, 2016
@caseyWebb
Copy link
Contributor Author

🍻

@caseyWebb caseyWebb deleted the issue-43 branch November 7, 2016 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants