Skip to content

pre-* events #43

@legastero

Description

@legastero

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions