Ratatouille v0.5.1 Ratatouille.Runtime.Command View Source

Commands provide a way to start an expensive call in the background and get the result back via Ratatouille.App.update/2.

Commands should be constructed via the functions below and not via the struct directly, as this is internal and subject to change.

Link to this section Summary

Functions

Returns a batch command given a list of commands. This simply provides a way to return multiple commands as a single one. Batch commands should not depend on one another---Ratatouille's runtime may run some or all of them in parallel and doesn't guarantee any particular order of execution.

Returns a new command that can be returned in the Ratatouille.App.update/2 or Ratatouille.App.init/1 callbacks.

Link to this section Types

Link to this section Functions

Link to this function

batch(cmds)

View Source
batch([t()]) :: t()

Returns a batch command given a list of commands. This simply provides a way to return multiple commands as a single one. Batch commands should not depend on one another---Ratatouille's runtime may run some or all of them in parallel and doesn't guarantee any particular order of execution.

Dependencies should be expressed via a single command or a sequence of commands orchestrated via the application model state.

Link to this function

new(func, message)

View Source
new((() -> term()), term()) :: t()

Returns a new command that can be returned in the Ratatouille.App.update/2 or Ratatouille.App.init/1 callbacks.

Takes an anonymous function and a message. The message is used to send a response back to your app along with the result. It can be any Erlang term, so it's also possible to include identifiers (e.g., {:finished, id}).