diff options
author | Hayleigh Thompson <me@hayleigh.dev> | 2022-03-20 10:58:23 +0000 |
---|---|---|
committer | Hayleigh Thompson <me@hayleigh.dev> | 2022-03-20 10:58:23 +0000 |
commit | 170a249f1bc5caae55ae5a3469f0fc6beef63568 (patch) | |
tree | 13a65659aa2aef065d1acf59af20a109df83eaa4 /src/lustre.gleam | |
parent | 06e3827589771da31bf033d304da4ba3a40c9cde (diff) | |
download | lustre-170a249f1bc5caae55ae5a3469f0fc6beef63568.tar.gz lustre-170a249f1bc5caae55ae5a3469f0fc6beef63568.zip |
:construction: Morphdom is dead, long live React.
Diffstat (limited to 'src/lustre.gleam')
-rw-r--r-- | src/lustre.gleam | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lustre.gleam b/src/lustre.gleam new file mode 100644 index 0000000..2058da6 --- /dev/null +++ b/src/lustre.gleam @@ -0,0 +1,46 @@ +//// + + +// IMPORTS --------------------------------------------------------------------- +import lustre/element +import lustre/attribute + + +// TYPES ----------------------------------------------------------------------- +/// +pub opaque type Program(state, action) { + Program( + init: state, + update: Update(state, action), + view: View(state, action) + ) +} + + +/// +pub type Element(action) = element.Element(action) +/// +pub type Attribute(action) = attribute.Attribute(action) + + +/// +type Update(state, action) = fn (state, action) -> state +type View(state, action) = fn (state) -> Element(action) + + +// CONSTRUCTORS ---------------------------------------------------------------- +/// +pub fn create (init: state, update: Update(state, action), view: View(state, action)) -> Program(state, action) { + Program(init, update, view) +} + + +/// +pub external fn start (program: Program(state, action), selector: String) -> Nil + = "./lustre/ffi.mjs" "mount" + + +// CONVERSIONS ----------------------------------------------------------------- +/// +pub external fn to_element (program: Program(state, action)) -> Element(a) + = "./lustre/ffi.mjs" "Program" |