Use case: I like to create my "app" component, then use app.on() API to bind event handlers on component events. Example:
var app = new App({
target: document.querySelector('main'),
data: someData
})
// Example listener outside the component hierarchy.
app.on('deleteUser', (event) => {
// etc...
})
Problem: In a nested component's oncreate method I might call this.fire('foo') but it's too early to use app.on() with and I miss that event.
So... what if I could pass in a map of event names -> functions to the "app" component's constructor? Or is there a better approach?
Use case: I like to create my "app" component, then use
app.on()API to bind event handlers on component events. Example:Problem: In a nested component's
oncreatemethod I might callthis.fire('foo')but it's too early to useapp.on()with and I miss that event.So... what if I could pass in a map of event names -> functions to the "app" component's constructor? Or is there a better approach?