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

pre-* events #43

Open
legastero opened this issue Jan 22, 2015 · 0 comments
Open

pre-* events #43

legastero opened this issue Jan 22, 2015 · 0 comments

Comments

@legastero
Copy link

It would be nice to have a chance before a model is actually inserted/removed from a collection or changed to enforce any collection invariants.

For example, say I have a collection of apple models, but I am only allowed to have one green apple at a time. On a pre-add I could check that the new apple is green and remove any existing green apple, and this would work regardless of what actually called the .add().

Likewise, if we had a pre-change event from ampersand-state, then the invariant could still be enforced when an apple changed from red to green, no matter where or what triggered the change.

Maybe a better example would be an invariant that there can be only a single model where selected is true.

(any pre-change event would be a matter for ampersand-state to implement, of course)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants