-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
Improve child->parent communication.
For the time being, child components can send events to parents in 2 ways:
- domain event (alway using a external domain class -> heavy)
- dom event (cannot be customizable -> bad)
Meanwhile, the first is well-typed and structured, but the second isn't.
We would likeSeqflowhelps the developer to buildCustomEventso the parent can listen it.
We can write something like
const MyNewDomEvent = createDomEventClass<{ foo: string }>('my-dom-event')
async function ChildComponent({}, { component }: Contexts) {
// something happen
component.dispatchEvent(new MyNewDomEvent({ foo: 'a string' }))
}
async function ParentComponent({}, { component }: Contexts) {
// render ChildComponent
const events = component.waitEvents(component.domEvent(MyNewDomEvent))
for await (const ev of events) {
console.log(ev) // ev instanceof MyNewDomEvent
}
}With this issue the assignee should:
- create and export a function
createDomEventClassto help the developer create custom dom event - improve the
domEventmethod to allow custom dom event
ThecreateDomainEventClassfunction can help.