Comments (3)
Kinda curious what the use case for hashes in particular is?
from compose.
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 */
const evented = 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):
function foo(evt: CustomEvent) { /* do something */ }
function bar(evt: CustomEvent) { /* do something */ }
evented.on({ foo, bar });
from compose.
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.
from compose.
Related Issues (20)
- Asynchronous initialization support? HOT 3
- Typescript 2.1 Merge Types HOT 2
- Remove deprecated `mixins` HOT 1
- Consider splitting createStateful HOT 1
- TypeScript 2.2 Object and Intersection Types HOT 2
- Update README to better reflect current design and usage
- API Doc Review for compose
- Upgrade to typescript 2.3.2
- Changes to Evented interfaces
- Changes to Stateful interfaces HOT 7
- Integration of dojo/interfaces
- Custom toString() is skipped by the factory HOT 1
- Additional Diagnostics HOT 3
- Proposal: Remove `.extend()` and replace with `.override()` HOT 5
- Stateful should emit a `state:initialized`
- Stateful should emit an initialization event HOT 1
- Stateful should emit "error" on observation error HOT 1
- Once initialized event has been emitted, subsequent events do not need to async HOT 1
- Events should not emit on the next turn and `state:initialized` is no longer required HOT 1
- Event globbing with Evented HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from compose.