diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-22 23:33:45 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-22 23:33:45 +0100 |
commit | 9bc9b6ae2664b63b02a8cb5a44660f7f225ad910 (patch) | |
tree | 086ac524707fb0798ff78b6b887d6fe8367be1f3 | |
parent | 3f5114d3ad44347763e5b53e69b31c38e38f9a97 (diff) | |
download | lustre-9bc9b6ae2664b63b02a8cb5a44660f7f225ad910.tar.gz lustre-9bc9b6ae2664b63b02a8cb5a44660f7f225ad910.zip |
:sparkles: Make it possible to manually destroy a running lustre app.
-rw-r--r-- | lib/src/lustre.ffi.mjs | 3 | ||||
-rw-r--r-- | lib/src/lustre.gleam | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/src/lustre.ffi.mjs b/lib/src/lustre.ffi.mjs index 51a6e26..29a60a9 100644 --- a/lib/src/lustre.ffi.mjs +++ b/lib/src/lustre.ffi.mjs @@ -122,7 +122,8 @@ export class App { } export const setup = (init, update, render) => new App(init, update, render); -export const start = (app, selector) => app.start(selector); +export const start = (app, selector, flags) => app.start(selector, flags); +export const destroy = (app) => app.destroy(); export const emit = (name, data) => // Normal `Effect`s constructed in Gleam from `effect.from` don't get told diff --git a/lib/src/lustre.gleam b/lib/src/lustre.gleam index 2585a5b..a8bdfd9 100644 --- a/lib/src/lustre.gleam +++ b/lib/src/lustre.gleam @@ -247,6 +247,9 @@ pub fn start( flags: flags, ) -> Result(fn(msg) -> Nil, Error) +@external(javascript, "./lustre.ffi.mjs", "destroy") +pub fn destroy(app: App(flags, model, msg)) -> Nil + // UTILS ----------------------------------------------------------------------- @external(javascript, "./lustre.ffi.mjs", "is_browser") |