seed icon indicating copy to clipboard operation
seed copied to clipboard

Commands and Orders

Open zinahe opened this issue 5 years ago • 2 comments

Hi,

Trying to get my head around some concepts. Can someone kindly shed some light on what commands and orders are ? Are they the same thing? If not, how they are different, conceptually ?

Who is being "order"ed here ? the run-time ? And who is the command for ? other components ? I'm confused.

Thanks,

zinahe avatar Jun 11 '20 03:06 zinahe

orders is a parameter in your init and update function that allows you to "give orders" to Seed. So orders are basically just method calls that Seed/runtime should handle.

commands are basically async operations - fetch, timeout, etc. So orders.perform_cmd(..) just executes the Future (it creates a Promise under the hood).

There are no components in The Elm architecture - when you call orders.perform_cmd from your update function, the same update function is called once the command has been performed. And yes, there are "TEA components", but each update and Msg of those "components" are just parts of the update/Msg tree (the tree that you've written by yourself).

There is no magic and special theory - every Msg has to go through your root update function.

MartinKavik avatar Jun 12 '20 10:06 MartinKavik

Thanks a lot. That helps. I think I somehow got React's components mixed up with Elm.

zinahe avatar Jun 13 '20 20:06 zinahe