feat(ElementEvents): batch subscription#586
Conversation
|
If this gets merged, then it should be encouraged over the other overload signature with traditional arguments: subscribe(
eventName: string,
handler: Function,
captureOrOptions?: boolean | AddEventListenerOption): EventHandler;as the third parameter value is |
zewa666
left a comment
There was a problem hiding this comment.
Love this idea. Just left a small remark
| export declare interface SubscriptionHandlerConfig { | ||
| handler: Function | ||
| capture?: boolean | ||
| passive?: boolean |
There was a problem hiding this comment.
Whats this passive prop for? I see it nowhere handled in code
There was a problem hiding this comment.
It is used when we pass the whole object to EventTarget.prototype.addEventListener third paramter. Same with passive in spec.
|
Would love to see this one merged, this is fantastic. |
|
How often do you actually need this? Usually you would subscribe to events in the view I would keep the API as it is, and not introduce a change with minimal gains |
|
bigopon seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
This PR enhance
ElementEventsclass with ability to subscribe to multiple events at once.Usage example:
Also compatible with
subscribeOnceThe result of
subscribe/subscribeOncewill be an plain object with same properties with input: