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 like Seqflow helps the developer to build CustomEvent so 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
createDomEventClass to help the developer create custom dom event
- improve the
domEvent method to allow custom dom event
The createDomainEventClass function can help.
Improve child->parent communication.
For the time being, child components can send events to parents in 2 ways:
Meanwhile, the first is well-typed and structured, but the second isn't.
We would like
Seqflowhelps the developer to buildCustomEventso the parent can listen it.We can write something like
With this issue the assignee should:
createDomEventClassto help the developer create custom dom eventdomEventmethod to allow custom dom eventThe
createDomainEventClassfunction can help.