You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.
When you have a lot of listeners to supply for different events. In particular it came up in the app factory, when configuring up certain instances, it is often easier to supply a map/hash, which is especially functional when combined with the terse method expression in object literals. It is also actually supported on creation already:
/* already works */constevented=createEvented({listeners: {foo(evt){/* handle event */}}});/* also this would work with the change */evented.on({bar(evt){/* handle event */},qat(evt){/* handle event */}});
As a consumer, you can register for all the events you care about and get a single handle return which would disconnect those listeners.
You can also use additional ES6 syntax to make it even more concise (and more easy to read what you are doing):
functionfoo(evt: CustomEvent){/* do something */}functionbar(evt: CustomEvent){/* do something */}evented.on({ foo, bar });
Oh, I didn't think about it enabling shorthand with ES6 syntax. But yeah, I've at least had a couple of occasions in the past where I've wanted a handle for a group of events and did that myself for an array.
To allow the listener to be an array of listeners as well as accept a map/hash of listeners.
The text was updated successfully, but these errors were encountered: