davedawkins/Sutil

Props never get updated in WebComponent with elmish

pkese opened this issue · 2 comments

pkese commented
let MyComponent (props : IStore<Props>) =
    let store, dispatch = Store.makeElmish Model.init update ignore props.Value
    use propsSubscription = props.Subscribe (PropsChanged >> dispatch)

In above code, PropsChanged message will always get delivered with initial value of props.
Events get fired, but value of props is always the same.

Normal IStore<Props> |> Store.map rendering code appears to work fine (below): Html text is changing correctly.
Just elmish (above) never sees any change.

    Bind.el(props |> Store.map (fun m -> m.text), Html.text)
pkese commented

Eh it was

use propsSubscription = ...

instead of

let propsSubscription = ...

so subscription got disposed at the end of code block.

I didn't even know we had use in F# - seems to work same as using (...) { ... } in C#.

I'm glad you fixed it, and thanks for logging the issue