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

Add ability to stop listening for changes #14

Merged
merged 1 commit into from
Jul 25, 2013
Merged

Add ability to stop listening for changes #14

merged 1 commit into from
Jul 25, 2013

Conversation

brandonpayton
Copy link
Contributor

Sometimes bindings outlive objects that depend on them. In those cases, we need the ability to remove receive callbacks associated with those objects.

I updated Binding.prototype.receive to return a handle with a remove method that can be called to remove the callback. This means that the get(property, callback) shorthand is somewhat broken in that get cannot return both a binding and a handle for callback removal. Because of this, I removed this shorthand from bind.js and the README. While I was in the README, I also corrected mention of binding.then to binding.receive.

What are your thoughts?

P.S. In getting to know dbind, the shorthand methods were a distraction from seeing the essential simplicity of the API. Perhaps it would be better if there was no shorthand for things like binding.get(prop).put(value).

@brandonpayton
Copy link
Contributor Author

I wrote a test for this change, but it was added on top of work by @neonstalwart to create intern-based unit tests for dbind. That branch is here: https://github.com/brandonpayton/dbind/tree/intern-remove-handle

I intended to add more tests for StatefulBinding, StatefulPropertyBinding, etc but made little progress. Rather than spend more time discerning between intentional behavior and bugs, I punted with the intent to ask you later about those objects.

@kriszyp
Copy link
Owner

kriszyp commented Jul 24, 2013

I understand the desire for simplicity but it had seemed the 2-arg get() and set() seem very convenient for the most common use cases. At least we should separate out the interface change to get() for consideration from the remove() addition, I think.

@brandonpayton
Copy link
Contributor Author

Thanks for taking a look at this. I understand. I'll separate the changes.

@brandonpayton
Copy link
Contributor Author

Kris, here is the isolated change for your review.

kriszyp added a commit that referenced this pull request Jul 25, 2013
Add ability to stop listening for changes
@kriszyp kriszyp merged commit a1af703 into kriszyp:master Jul 25, 2013
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.

2 participants