Factory for creating common command values. More...
Static Public Member Functions | |
| static ? ICmd | Batch (params ICmd?[] cmds) |
| Run all commands concurrently. | |
| static ICmd | Debounce (string key, TimeSpan interval, Func< DateTimeOffset, IMsg > fn) |
| Invokes fn once interval has passed without another dispatch under key . | |
| static ICmd | Msg (IMsg msg) |
| Returns the given message immediately (synchronous, no async gap). | |
| static ICmd | Quit () |
| Returns QuitMsg immediately, ending the program loop. | |
| static ICmd | Run (Func< CancellationToken, Task< IMsg > > fn) |
| Wrap an async function as a command. | |
| static ICmd | Run (Func< CancellationToken, Task< IMsg > > fn, CancellationToken cancellationToken) |
| Wrap an async function as a command, binding a specific CancellationToken at creation time. | |
| static ? ICmd | Sequence (params ICmd?[] cmds) |
| Run commands serially: each waits for the previous to complete. | |
| static ICmd | Throttle (string key, TimeSpan interval, Func< DateTimeOffset, IMsg > fn) |
| Invokes fn at most once per interval under key , on the leading edge. | |
| static ICmd | Tick (TimeSpan interval, Func< DateTimeOffset, IMsg > fn, CancellationToken cancellationToken=default) |
| Fire once after interval . | |
Static Public Attributes | |
| static readonly? ICmd | None = null |
| No-op command. Framework skips dispatch. | |
Factory for creating common command values.
Run all commands concurrently.
Null commands filtered out. Returns null if zero cmds remain; the single cmd if one remains. Each command's message is delivered as soon as that command completes — batching is NOT a barrier (a slow fetch doesn't delay a fast tick). Nesting is safe: an inner Batch dispatches its own children the same way.
|
static |
Invokes fn once interval has passed without another dispatch under key .
Re-dispatching inside the window supersedes the pending invocation and restarts it; the superseded one produces no message at all.
The window belongs to key and is held by the running App, not by the returned cmd, so a cmd built fresh in Update — the only way the Elm loop builds one — debounces correctly. The most recent fn under a key is the one that runs, so a closure that varies per item is safe.
Keys are namespaced by the application, as subscription keys are. A window still open when the program exits is cancelled rather than fired.
| key | Identifies the window. Dispatches sharing it supersede one another. |
Returns the given message immediately (synchronous, no async gap).
Useful when a model update needs to dispatch a follow-up message (e.g. ThemeChangedMsg) in the same event-loop tick.
Wrap an async function as a command.
fn receives a CancellationToken that is cancelled when the program is shutting down.
Run commands serially: each waits for the previous to complete.
Null commands filtered out.
|
static |
Invokes fn at most once per interval under key , on the leading edge.
Dispatches inside the window are dropped rather than delayed, and produce no message.
As with Debounce, the window is held by the running App against key , so a cmd built fresh in Update throttles correctly. Keys persist for the life of the program — throttle against a fixed key, not a per-item identifier.
| key | Identifies the window. Dispatches sharing it share one rate limit. |
|
static |
Fire once after interval .
Returns fn(timestamp) as the message. Pass a CancellationToken to allow cancellation on program shutdown.