crux_core

Module command

Source
Expand description

Command represents one or more side-effects, resulting in interactions with the shell. Core creates Commands and returns them from the update function in response to events. Commands can be created directly, but more often they will be created and returned by capability APIs.

A Command can execute side-effects in parallel, in sequence or a combination of both. To allow this orchestration they provide both a simple synchronous API and access to an asynchronous API.

Command surfaces the effect requests and events sent in response with the Command::effects and Command::events methods. These can be used when testing the side effects requested by an update call.

Internally, Command resembles FuturesUnordered: it manages and polls a number of futures and provides a context which they can use to submit effects to the shell and events back to the application.

Command implements Stream, making it useful in an async context, enabling, for example, wrapping Commands in one another.

§Examples

TODO: simple command example with a capability API

TODO: complex example with sync API

TODO: basic async example

TODO: async example with spawn

TODO: cancellation example

TODO: testing example

TODO: composition example

Structs§

Enums§

  • An item emitted from a Command when used as a Stream.