Open tcoopman opened 3 years ago
I've found a way to simulate this:
type 'msg Vdom.Cmd.t += Run of (('msg -> unit) -> unit)
let update model = function
| `Async ->
return
model
~c:
[ Run (fun send -> send `Msg)]
let cmd_handler ctx = function
| Run cb ->
cb (fun x -> Vdom_blit.Cmd.send_msg ctx x) ;
true
| _ ->
false
let () = Vdom_blit.(register (cmd { f = cmd_handler }))
Still it would be nice to have this as a build-in option
Bucklescript-tea has Tea_cmd.call which allows you to enqueue callbacks for example in the update of the model.
This makes handling callbacks from websockets for example much easier. A Ws implementation could look something like this: