-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dice_ui.spi
42 lines (31 loc) · 1.21 KB
/
dice_ui.spi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
open rust.rust_operators
open rust
open leptos
inl main (args : array_base string) =
leptos.log $'"main / args: " + string !args + ""'
!\($'"let _ = console_log::init_with_level(log::Level::Debug)"')
!\($'"console_error_panic_hook::set_once()"')
inl body : optionm'.option' wasm.html_element = !\($'"leptos::prelude::document().body()"')
inl body = body |> optionm'.unbox
inl body_log = body |> sm'.format_debug
leptos.log $'"main / mount_to_body / body: " + string !body_log + ""'
let mount () =
fun () =>
components.app.render ()
|> leptos.to_view_trait
|> leptos.mount_to_body
match body with
| Some body =>
body |> wasm.set_inner_html ""
mount ()
| _ =>
inl fn : rust.box (rust.dyn' rust.fn_unit) = rust.box_fn mount
inl fn_closure = fn |> wasm.closure_wrap
inl fn = fn_closure |> wasm.closure_as_ref |> wasm.unchecked_ref
!\($'"leptos::prelude::document().add_event_listener_with_callback(\\\"DOMContentLoaded\\\", !fn).unwrap()"')
fn_closure |> wasm.closure_forget
0i32
inl main () =
print_static "<dice_ui>"
$'let main args = !main args' : ()
print_static "</dice_ui>"