Open SchlenkR opened 7 months ago
... https://twitter.com/1kap10/status/1729502984071979313
I'd like to implement a global persistent record. It reads json from localstorage on startup and encode and save the record to storage on every update. Here is how it's done in svelte:
PS: The repl is sandboxed so it won't work there.
Hi, thank you for the project! I'm giving it a try and it's not a clear how to use global state. This is what I've tried, but it doesn't work
let globalCount<'a> = ofMutable {0}
let counter =
vide {
div {
let! count = ofMutable {0}
let! gv = globalCount
button.onclick(fun _ ->
count.Value <- count.Value + 1
gv.Value <- gv.Value + 1
) {
$"Count"
}
$"Value={count.Value} Global={gv.Value}"
}
}
let view =
vide {
do! counter
do! counter
}
UPD: I've managed to make global state using standard F# DI approach https://gist.github.com/Lanayx/7b9426cbb11ed7a2ffa29c83e6653a24
https://twitter.com/1kap10/status/1729494967205105781
Nice project, would like to see examples with global state management, listening to window events and json handling.
How do rendering work? Vdom/Signals/Rerender everything or something else?