aboutsummaryrefslogtreecommitdiff
path: root/src/client-runtime.ffi.mjs
diff options
context:
space:
mode:
authorHayleigh Thompson <me@hayleigh.dev>2024-03-11 05:48:53 +0100
committerHayleigh Thompson <me@hayleigh.dev>2024-03-12 08:04:11 +0100
commitc0042287511c6aaa3447f9ffc38a095add939a25 (patch)
tree3a1c2629299bedc8babf35a35cfad697639467e8 /src/client-runtime.ffi.mjs
parent1e6354995552ff44d1527874c36ccb7de3b45f28 (diff)
downloadlustre-c0042287511c6aaa3447f9ffc38a095add939a25.tar.gz
lustre-c0042287511c6aaa3447f9ffc38a095add939a25.zip
:recycle: Add a 'Map' vdom node for more efficient msg mapping.
Diffstat (limited to 'src/client-runtime.ffi.mjs')
-rw-r--r--src/client-runtime.ffi.mjs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/client-runtime.ffi.mjs b/src/client-runtime.ffi.mjs
index 12c8627..ab80fbf 100644
--- a/src/client-runtime.ffi.mjs
+++ b/src/client-runtime.ffi.mjs
@@ -71,8 +71,12 @@ export class LustreClientApplication {
const vdom = this.#view(this.#model);
this.#didUpdate = false;
- this.#root = morph(this.#root, vdom, (msg) => {
- this.send(new Dispatch(msg));
+ this.#root = morph(this.#root, vdom, (handler) => (e) => {
+ const result = handler(e);
+
+ if (result.isOk()) {
+ this.send(new Dispatch(result[0]));
+ }
});
}