aboutsummaryrefslogtreecommitdiff
path: root/lib/src/lustre.ffi.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/lustre.ffi.mjs')
-rw-r--r--lib/src/lustre.ffi.mjs8
1 files changed, 6 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 = [];