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

Implement #484 : hookState #485

Merged
merged 2 commits into from
Mar 5, 2015

Conversation

fabien
Copy link
Contributor

@fabien fabien commented Mar 5, 2015

This implements #484

@altsang altsang added the #review label Mar 5, 2015
@fabien fabien mentioned this pull request Mar 5, 2015
@fabien
Copy link
Contributor Author

fabien commented Mar 5, 2015

@bajtos @raymondfeng thoughts?

@bajtos
Copy link
Member

bajtos commented Mar 5, 2015

@raymondfeng @ritch If you have any objections against hookState, then speak now. Otherwise I'll review and land this PR later today/early tomorrow CET.

Model.notifyObserversOf('before save', { Model: Model, instance: obj }, function(err) {
Model.notifyObserversOf('before save', {
Model: Model, instance: obj, hookState: hookState
}, function(err) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coding style: please move the context initialisation to a new line and property.

var context = ...;
Model.notifyObserversOf('before save', context, function(err) {

The same fix should be applied to all other places where the context initialization does not fit a single line.

IIRC, we are already using the style described above in other existing code, so let's keep the style consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

@fabien
Copy link
Contributor Author

fabien commented Mar 5, 2015

@bajtos I'm running out of time here, with zero progress today (and lost work from yesterday).

I moved ahead with #486 - how I can I make sure I don't have to redo that?

@fabien
Copy link
Contributor Author

fabien commented Mar 5, 2015

@bajtos reformatted and fixed - except for hookState.test, which should remain - perhaps be renamed, but otherwise is required to test all hooks.

@ritch
Copy link
Contributor

ritch commented Mar 5, 2015

No qualms here. Just a reminder that we need an example for this.

@raymondfeng
Copy link
Contributor

LGTM.

@fabien
Copy link
Contributor Author

fabien commented Mar 5, 2015

OK, can anyone merge then please?

raymondfeng added a commit that referenced this pull request Mar 5, 2015
@raymondfeng raymondfeng merged commit 6b04568 into loopbackio:master Mar 5, 2015
@bajtos
Copy link
Member

bajtos commented Mar 5, 2015

I am very unhappy about this merge, since when do we prefer quick merges at the cost of code quality? The code coverage is low, the fact that the state is shared between hooks is tested only for before/after delete hooks. The technique using hookState.test is too magic, it will be difficult to understand for anybody not familiar with this pull request (including us in few months) and it makes the future maintenance more difficult.

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.

5 participants