Open awaynemd opened 1 year ago
I take it that it is pretty important that EventMediator
be initialized lazily? Otherwise, of course, you could use an F# module instead of hand-writing a static class.
Once triggered, it is received in a separate module
Where is the separate module in your code structure? The means by which you will send RequestAppointmentsMsg
to the dispatcher depends on the location of the event handler. If your WPF code handles the event, make an Elmish.WPF command binding in your view model that returns message RequestAppointmentsMsg
, then execute the binding's ICommand
from your WPF code. If the event handler isn't accessible to your WPF code but is accessible to your main
function (step 7 in the README), you can pass the dispatcher into the class constructor as an argument, then use Elmish.Cmd.ofEffect
to connect it to the Elmish loop. But this method is significantly more complicated, so I would need more information to walk you through it.
Do not simultaneously cross post: https://stackoverflow.com/q/76547050/741786
This is a repost of a StackOverflow question.
In Elmish.wpf, I have a custom event as a singleton:
type EventMediator private () = let mutable _name = "";
Once triggered, it is received in a separate module as:
let p = EventMediator.Instance p.NameChanged.Add(fun () -> dispatch RequestAppointmentsMsg ) <--WRONG! where RequestAppointmentsMsg is defined (Elemish.wpf) as
type Msg =
| RequestAppointmentsMsg The call-back to the event is outside of the Update loop.
How can I send the message "RequestAppointmentsMsg" in Elmish.wpf to the dispatcher so it will be acted upon by the Update loop?
Thank you.
Note: the signature for the update loop is:
update (msg:Msg) (m:Registration) : Registration * Cmd = ....