Fun Blazor
Global storage
Open two browsers for this page and try to click the toggle button

Toggled off now

[<AutoOpen>]
module Fun.Blazor.Docs.Wasm.Pages.HelperFunctions.GlobalStoreDemo

open MudBlazor
open Fun.Blazor

let globalStoreDemo = html.inject (fun (store: IGlobalStore) ->
    let toggle = store.Create ("global-store-toggle", false)
    
    MudPaper'() {
        Styles [ style.padding 20 ]
        childContent [
            html.watch (toggle, fun isToggled -> [
                MudText'() {
                    childContent "Open two browsers for this page and try to click the toggle button"
                    Typo Typo.subtitle1
                }
                MudSwitch'<bool>() {
                    Checked isToggled
                    CheckedChanged (fun (x: bool) -> toggle.Publish x)
                }
                if isToggled then
                    MudText'() {
                        childContent "Toggled successfuly"
                        Typo Typo.subtitle2
                        Color Color.Primary
                    }
                else
                    MudText'() {
                        childContent "Toggled off now"
                        Color Color.Secondary
                    }
            ])
        ]
    })