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

Fixed model.remove ignoring callback #1210

Merged
merged 3 commits into from Nov 14, 2012
Merged

Conversation

bratchenko
Copy link
Contributor

I don't know if this behavior was intended, but it's wrong. 
If I call .remove on the same model twice for whatever reason, second call will never execute callback, which will break execution flow.

I don't know if this behavior was intended, but it's wrong. 
If I call .remove on the same model twice for whatever reason, second call will never execute callback, which will break execution flow.
@@ -661,9 +661,7 @@ Model.prototype._where = function _where (where) {
*/

Model.prototype.remove = function remove (fn) {
if (this._removing) return this;
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch. there's no reason to remove the same document twice but we definitely need to execute the callback.

we should keep the promise and just add the fn to it.

promise.addBack(fn)

just call Promise.addBack with new callback. No need to actually remove model twice.
@bratchenko
Copy link
Contributor Author

Yes, calling addBack with new callback seems more sensible behavior. I've changed patch.

aheckmann added a commit that referenced this pull request Nov 14, 2012
Fixed model.remove ignoring callback
@aheckmann aheckmann merged commit cd36dd5 into Automattic:master Nov 14, 2012
@aheckmann
Copy link
Collaborator

merged! thanks

aheckmann added a commit that referenced this pull request Nov 14, 2012
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.

None yet

2 participants