Adding ability for stateful views to 'emit' events to their update functions. enhancing state tree viewer

This commit is contained in:
Dustin Swan 2026-02-15 16:57:22 -07:00
parent 69407cd25b
commit 6f217a0923
No known key found for this signature in database
GPG key ID: 30D46587E2100467
6 changed files with 111 additions and 77 deletions

View file

@ -92,7 +92,9 @@ export function runAppCompiled(canvas: HTMLCanvasElement, store: any) {
setFocus(fullKey);
}
const viewResult = instance.view(instance.state);
const emit = (event: any) => ({ _tag: 'ComponentEvent', _0: fullKey, _1: event });
const viewResult = instance.view(instance.state)(emit);
const viewUI = {
kind: 'clickable',
child: viewResult,
@ -206,6 +208,11 @@ export function runAppCompiled(canvas: HTMLCanvasElement, store: any) {
return;
}
if (event._tag === 'ComponentEvent') {
handleComponentEvent(event._0, event._1);
return;
}
if (event._tag === 'NoOp')
return;
}