Open ebenezerdon opened 3 years ago
Hi @ebenezerdon,
I would recommend to look at some examples like https://github.com/seed-rs/seed/blob/master/examples/subscribe/src/lib.rs or https://github.com/seed-rs/seed/blob/master/examples/fetch/src/simple.rs (just look for orders.
in the linked code).
You need to use orders
when you want to interact with the App
instance (directly or indirectly).
Example: Call orders.subscribe(Msg::UrlChanged)
stores a new subscription in the app instance.
Or orders.perform_cmd(...)
performs the given command (i.e. spawns the Future
on the current thread) and the output message is then pushed to the internal queue in the app instance and then finally passed to your update
function.
So orders
is basically a way to safely and explicitly perform side-effects in your app. (And it has also some other useful methods to improve developer experience.)
Does it make more sense?
Cheers, Martin
Hi @ebenezerdon,
I would recommend to look at some examples like https://github.com/seed-rs/seed/blob/master/examples/subscribe/src/lib.rs or https://github.com/seed-rs/seed/blob/master/examples/fetch/src/simple.rs (just look for
orders.
in the linked code).You need to use
orders
when you want to interact with theApp
instance (directly or indirectly). Example: Callorders.subscribe(Msg::UrlChanged)
stores a new subscription in the app instance. Ororders.perform_cmd(...)
performs the given command (i.e. spawns theFuture
on the current thread) and the output message is then pushed to the internal queue in the app instance and then finally passed to yourupdate
function.So
orders
is basically a way to safely and explicitly perform side-effects in your app. (And it has also some other useful methods to improve developer experience.)Does it make more sense?
Cheers, Martin
Thanks, @MartinKavik. This makes more sense. If you don't mind, I'd appreciate it if the documentation is also updated with the explanation you've provided here. Thanks a lot!
I'd appreciate it if the documentation is also updated with the explanation you've provided here.
=> reopening to not forget to add it in the future
Currently, the
orders
parameter is a bit difficult to understand. Can you help go through the edit to see if I understood it correctly, myself? If so, I would like to contribute to making it easier for others too.