Skip to content

Commit

Permalink
✨ Add additional errors for other cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
hayleigh-dot-dev committed Aug 19, 2023
1 parent 37564e4 commit 8ddc115
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/src/lustre.ffi.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import {
ElementNotFound,
AppAlreadyStarted,
AppNotYetStarted,
ComponentAlreadyRegistered,
ElementNotFound,
NotABrowser,
} from "./lustre.mjs";
import { from } from "./lustre/effect.mjs";
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -65,6 +67,8 @@ export class App {
}

destroy() {
if (!this.#root) return new Error(new AppNotYetStarted());

this.#root.remove();
this.#state = null;
this.#queue = [];
Expand Down
2 changes: 2 additions & 0 deletions lib/src/lustre.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import lustre/element.{Element}
pub type App(flags, model, msg)

pub type Error {
AppAlreadyStarted
AppNotYetStarted
ComponentAlreadyRegistered
ElementNotFound
NotABrowser
Expand Down

0 comments on commit 8ddc115

Please sign in to comment.