From 8ddc115f92368a29ef710977f3a377ad4d854c48 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 19 Aug 2023 23:02:22 +0100 Subject: :sparkles: Add additional errors for other cases. --- lib/src/lustre.ffi.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/src/lustre.ffi.mjs') 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 = []; -- cgit v1.2.3