run abstract method
Dynamically run saga
. Can be used to run Sagas only after the
applyMiddleware and SagaMiddleware.setStore phase.
The method returns a Task descriptor.
Notes
saga
must be a synchronous generator function
which returns a Iterable object.
The middleware will then iterate over the Generator and execute all yielded
Effects.
saga
may also start other sagas using the various Effects provided by the
library. The iteration process described below is also applied to all child
sagas.
In the first iteration, the middleware invokes the moveNext()
method to
retrieve the next Effect. The middleware then executes the yielded Effect
as specified by the Effects API below. Meanwhile, the Generator will be
suspended until the effect execution terminates. Upon receiving the result
of the execution, the middleware calls moveNext()
again. This process is repeated
until the Generator terminates normally or by throwing some error.
If the execution results in an error (as specified by each Effect creator)
then the Catch
method is called instead. If the
Generator function defines a Try/Catch
surrounding the current yield
instruction, then the Catch
block will be invoked by the underlying
Generator runtime. The runtime will also invoke any corresponding Finally
block.
In the case a Saga is cancelled (either manually or using the provided Effects), the middleware will stop execution of the Generator function. This will cause the Generator to skip directly to the finally block.
saga
is a Generator function with the return type of Iterable
If it is required arguments args
and namedArgs
can be provided to saga
.
Unhandled errors can be caught by Catch
.
If provided Finally
will be invoked before stopping execution of saga
Both Catch
and Finally
can be either a saga generator or sync/async function
An optional name
can be provided in order to ease trace/debug operations
Implementation
Task run(Function saga,
{List<dynamic> args,
Map<Symbol, dynamic> namedArgs,
Function Catch,
Function Finally,
String name});