Factory for creating common command values. More...
Static Public Member Functions | |
| static ? ICmd | Batch (params ICmd?[] cmds) |
| Run all commands concurrently. | |
| static ICmd | Debounce (TimeSpan interval, Func< DateTimeOffset, IMsg > fn) |
| Returns a cmd that, when dispatched, waits interval after the last dispatch before invoking fn . | |
| 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 (TimeSpan interval, Func< DateTimeOffset, IMsg > fn) |
| Returns a cmd that forwards at most one invocation per interval . | |
| 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.
Returns a cmd that, when dispatched, waits interval after the last dispatch before invoking fn .
If re-dispatched within the window the previous pending invocation is cancelled and the window resets.
Note: debouncing state is held in the returned closure. Use a single stored reference to the same cmd instance across re-dispatches for correct behaviour.
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.
Returns a cmd that forwards at most one invocation per interval .
Calls within the throttle window are dropped (not delayed).
|
static |
Fire once after interval .
Returns fn(timestamp) as the message. Pass a CancellationToken to allow cancellation on program shutdown.