-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
feat(ElementEvents): batch subscription #586
base: master
Are you sure you want to change the base?
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats this passive prop for? I see it nowhere handled in code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
ElementEvents
class with ability to subscribe to multiple events at once.Usage example:
Also compatible with
subscribeOnce
The result of
subscribe
/subscribeOnce
will be an plain object with same properties with input: