SoloContext<S extends Object, W extends S> class abstract interface

The core context plus the state: what a job body of solo sees.

The state is narrowed to the job's working type W, and emit is the only way to change it. Reading it is a checkpoint of its own: state, stateAs and check throw the job's Cancelled once its rules stopped holding, and so does each, whose child would keep them. emit throws a StateError for a job that has already finished.

A child handed to run, start or runAll is made by job(...) of the same controller or by child. A Job.deferred of the core, or a job of another controller, passes the types and is refused with an ArgumentError:

final name = await ctx.run(job<Idle, String>((child) => api.fetchName()));

See Children and chains for the rules a child starts under.

Implemented types

Properties

hashCode → int
The hash code for this object.
no setterinherited
heldCancellation → Cancelled?
The cancellation an open uncancellable section of this job is holding back, or null.
no setterinherited
job → Job<Object?>
The job this context belongs to.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
state → W
The current state.
no setter

Methods

abandonable<T>(FutureOr<T> action(), {FutureOr<void> dispose(T value)?, FutureOr<void> discard(T value)?}) → Future<T>
Runs action and waits for it, but no longer than this job lives.
inherited
check() → void
Gives up if the job was cancelled, or if a rule its engine adds stopped holding.
inherited
child<T>(Future<T> body(SoloContext<S, W> ctx), {Object? key, String describe()?, Duration? timeout}) → SoloJob<T>
Makes an unstarted child of this controller under this job's rules, for run, start and runAll.
override
disown(Object value) → bool
Drops the cleanup registered for value by abandonable, join or run.
inherited
each<T>(Stream<T> stream, FutureOr<void> onData(SoloContext<S, W> ctx, T event), {Object? key, String describe()?}) → SoloJob<void>
Starts a stream-processing child with its own SoloContext.
override
emit(S next) → void
Sets the controller state.
join<T>(FutureOr<T> action(), {FutureOr<void> dispose(T value)?, FutureOr<void> discard(T value)?}) → Future<T>
Runs action, waits for all of it, and gives up only afterwards.
inherited
log(Object? message) → void
Hands message to JobObserver.onLog as it is.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onCancel(void callback()) → void Function()
Registers callback to run the moment the job accepts a cancellation, before the body itself learns about it.
inherited
onDiscard(FutureOr<void> disposer()) → void Function()
Registers disposer to run unless the job ends Done: when it is cancelled, or fails.
inherited
onDispose(FutureOr<void> disposer()) → void Function()
Registers disposer to run when the job ends, whatever the outcome.
inherited
pause([Duration duration = Duration.zero]) → Future<void>
Waits for duration, or until the job is cancelled.
inherited
run<T>(ChildJob<T> child, {FutureOr<void> dispose(T value)?, FutureOr<void> discard(T value)?}) → Future<T>
Runs child, made by job(...) of this controller or by ctx.child, as a child of this job and returns its value.
override
runAll<T>(Iterable<ChildJob<T>> children) → Future<List<T>>
Runs children, each made by job(...) of this controller or by ctx.child, side by side, and stops the rest as soon as one of them goes wrong.
override
start(ChildJob<Object?> child) → void
Starts child, made by job(...) of this controller or by ctx.child, right now as a child of this job, and leaves its outcome to whoever holds it.
override
stateAs<T extends S>() → T
state narrowed to T; cancels the job with Cancelled(rules, 'is not T') on mismatch.
toString() → String
A string representation of this object.
inherited
unattended(FutureOr<void> action()) → void
Runs action as work this job does not wait for.
inherited
uncancellable<T>(FutureOr<T> action()) → Future<T>
Runs action with the cancellation held back, and waits for it.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited