RunicDraftFlush class

Namespace Runic.Navigation in Runic.Navigation 0.23.0

public static class RunicDraftFlush

Writes the drafts that presentations of a model context hold before a departure is decided: a web page's field that waits to write what the user typed (commit: "pause"), for example. The navigator flushes its RunicNavigator.ModelContext before it asks the departure guards of a transition that has any, so a guard that reads IsDirty sees the user's last input. Presentation hosts register a flush; applications rarely call it.

Remarks

Flushes are per model context: a departure flushes the presentations of its own models, not those of another window with another context. Runic.Application.Views registers each window's session with the window's context, until the session is disposed: it asks every page that uses the field-flush/1 feature to write its drafts and waits up to a short limit for them.

A flush must not wait for the model context's turn: the drafts it writes run in turns of their own.

Methods

FlushAsync

public static ValueTask FlushAsync(IRunicModelContext context, CancellationToken cancellationToken = default)

Runs every flush registered for context at once and completes when all completed. A flush that fails or is cancelled does not fail the others or the caller: the departure is then decided on the state as it is.

Register

public static IDisposable Register(IRunicModelContext context, Func<CancellationToken, ValueTask> flush)

Registers a flush of context's presentations until the result is disposed.