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
Proposal in Progress: Standardizing events #4656
Comments
@justinbmeyer can we make please this interface? with subscribe and unsubscribe? |
@frank-dspeed please create another issue for that. I think something like that can be created on-top of CanJS's symbols APIs, but it can't be the underlying primitive CanJS uses without too many breaking changes. |
Patches look like: Property events look like: {type: "propertyName", oldValue, newValue} DOM events look like:
|
I think patches, dispatched events on objects, and dispatched events on single value observables should all be unified. Here's the ideal: map.on("keyName", (event) => {
event //-> {type: "set", key: "keyName", newValue: 1, oldValue: 0, target: map}
} ) // same as canReflect.onEvent(map, "keyName", handler );
obs.on( (event) => {
event //-> {type: "value", newValue: 1, oldValue: 0, target: obs}
} ) // same as canReflect.onEvent( map, handler ); I think we can get there as follows: 1. Update observables to have new values:map.on("keyName", (event) => {
event /* -> {
type: "keyName",
eventType: "set",
key: "keyName",
newValue: 1,
oldValue: 0,
target: map } */
} ) // same as canReflect.onEvent(map, "keyName", handler ); We could also make Then in |
Instead of
|
I like |
Just putting it out there as a possibility; |
Random notes:
¿ what to do with batches ? |
Peculiarities about the current events implementation.
Some things we talked about on 5/29:
More thoughts later. |
Currently, CanJS has too many ways of listening to events.
.on
,onKeyValue
,onEvent
,onPatches
, etc. Also I'd like to take destructuring into account ...I'd like to consolidate this and simplify for CanJS 6. Everything will consolidate to an event object:
So instead of:
Everything will be on the event object:
There will be no more
event, newValue, oldValue
arguments . This is a breaking change, but I think we can move people to it.The text was updated successfully, but these errors were encountered: