From 13c992d2fb8ba4d4825c452be023da8c53af9488 Mon Sep 17 00:00:00 2001 From: Hayleigh Thompson Date: Sat, 19 Aug 2023 22:59:08 +0100 Subject: :sparkles: Return an error when components and applications are used outside of a browser-like environment. --- lib/src/lustre.gleam | 10 +++++++++- lib/src/lustre/element/hooks.gleam | 0 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/src/lustre/element/hooks.gleam diff --git a/lib/src/lustre.gleam b/lib/src/lustre.gleam index 4c9ff22..dcfe76a 100644 --- a/lib/src/lustre.gleam +++ b/lib/src/lustre.gleam @@ -50,8 +50,9 @@ import lustre/element.{Element} pub type App(flags, model, msg) pub type Error { - ElementNotFound ComponentAlreadyRegistered + ElementNotFound + NotABrowser } // CONSTRUCTORS ---------------------------------------------------------------- @@ -243,3 +244,10 @@ pub fn start( selector: String, flags: flags, ) -> Result(fn(msg) -> Nil, Error) + +// UTILS ----------------------------------------------------------------------- + +@external(javascript, "./lustre.ffi.mjs", "is_browser") +pub fn is_browser() -> Bool { + False +} diff --git a/lib/src/lustre/element/hooks.gleam b/lib/src/lustre/element/hooks.gleam new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3