diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-19 23:02:22 +0100 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2023-08-19 23:02:22 +0100 |
commit | 8ddc115f92368a29ef710977f3a377ad4d854c48 (patch) | |
tree | d12617e4bf50538539d4cd1afedbfdfa47628471 | |
parent | 37564e471b81247412fa837d1729ac0ca6d7a846 (diff) | |
download | lustre-8ddc115f92368a29ef710977f3a377ad4d854c48.tar.gz lustre-8ddc115f92368a29ef710977f3a377ad4d854c48.zip |
:sparkles: Add additional errors for other cases.
-rw-r--r-- | lib/src/lustre.ffi.mjs | 8 | ||||
-rw-r--r-- | lib/src/lustre.gleam | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/src/lustre.ffi.mjs b/lib/src/lustre.ffi.mjs index 2d07394..c7008ed 100644 --- a/lib/src/lustre.ffi.mjs +++ b/lib/src/lustre.ffi.mjs @@ -1,6 +1,8 @@ import { - ElementNotFound, + AppAlreadyStarted, + AppNotYetStarted, ComponentAlreadyRegistered, + ElementNotFound, NotABrowser, } from "./lustre.mjs"; import { from } from "./lustre/effect.mjs"; @@ -31,7 +33,7 @@ export class App { start(selector, flags) { if (!is_browser()) return new Error(new NotABrowser()); - if (this.#root) return this; + if (this.#root) return new Error(new AppAlreadyStarted()); const el = document.querySelector(selector); @@ -65,6 +67,8 @@ export class App { } destroy() { + if (!this.#root) return new Error(new AppNotYetStarted()); + this.#root.remove(); this.#state = null; this.#queue = []; diff --git a/lib/src/lustre.gleam b/lib/src/lustre.gleam index dcfe76a..ec04f3e 100644 --- a/lib/src/lustre.gleam +++ b/lib/src/lustre.gleam @@ -50,6 +50,8 @@ import lustre/element.{Element} pub type App(flags, model, msg) pub type Error { + AppAlreadyStarted + AppNotYetStarted ComponentAlreadyRegistered ElementNotFound NotABrowser |