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

Change variable name in adapter.observe to avoid argument capture into closure #546

Merged
merged 1 commit into from Jan 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/adapter.coffee
Expand Up @@ -77,7 +77,7 @@ Rivets.public.adapters['.'] =
callbacks = map.callbacks

if callbacks[keypath]
callback() for callback in callbacks[keypath].slice() when callback in callbacks[keypath]
cb() for cb in callbacks[keypath]
Copy link
Collaborator

Choose a reason for hiding this comment

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

@blikblum I understand this now. Why do you think the original author was cloning the array and checking with when? Is there a reason you haven't followed this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it was an oversight or remaining of a refactoring

We already know that the callback is in the array, since we just looped over it. There's no need to check again if is in the array. Looking at the JS generated code helps to understand.

@observeMutations newValue, obj[@id], keypath

unless callback in callbacks[keypath]
Expand Down