Closed PawelStadnicki closed 10 months ago
What is the setup of your project?
(also maybe trying with FunInteractiveWebAssembly
could help)
In a plain wasm project (or an interactive auto project) it should work just fine.
If you have code/repo where one can take a look at it would be nice
@PawelStadnicki my simple demo like below is working as expected:
open Microsoft.AspNetCore.Components
open Elmish
open Fun.Blazor
module Counter =
type Model = { Count: int }
type Msg =
| Increase
| Decrease
let init () = { Count = 0 }, Cmd.none
let update msg model =
match msg with
| Increase -> { Count = model.Count + 1 }, Cmd.none
| Decrease -> { Count = model.Count - 1 }, Cmd.none
let view (model: Model) (dispatch: Msg -> unit) = div {
p { $"Count = {model.Count}" }
button {
onclick (fun _ -> dispatch Increase)
"Increase"
}
}
[<Route "/counter">]
// [<FunInteractiveAuto>]
[<FunInteractiveWebAssembly>]
type Counter() =
inherit FunComponent()
override _.Render() = html.elmish (Counter.init, Counter.update, Counter.view)
Pls provide your code, so we can investigate it.
First of all, this is an excellent project! I will work with it in the following weeks and twitt about it. I still don't know too much about Blazor, and when I run Elmish code in Wasm it does not hit the update function. The init() is called that return Cmd.of Msg.Something but update never runs.
If I change the component attribute to FunInteractiveServer it works as expected. Are you seeing the same or I have something wrong on my side?
Thanks in advance