Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ideas for Samples #13

Open
SchlenkR opened this issue Nov 28, 2023 · 2 comments
Open

Ideas for Samples #13

SchlenkR opened this issue Nov 28, 2023 · 2 comments

Comments

@SchlenkR
Copy link
Owner

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?

@Lanayx
Copy link

Lanayx commented Dec 8, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants