Options class

Optional parameters can be passed to middleware creation.

Below there is an example creation of middleware with options. In the example, onError option is passed in order to handle uncaught middleware errors.

Example

//create options
var options = Options(
  //add an option to handle uncaught errors
  onError: (dynamic e, String s) {
    //print uncaught errors to the console
    print(e);
  },
);

// create middleware and pass options
var sagaMiddleware = createSagaMiddleware(options);

// create store and apply middleware
final store = Store<int>(
  counterReducer,
  initialState: 0,
  middleware: [applyMiddleware(sagaMiddleware)],
);

// set store
sagaMiddleware.setStore(store);

// run root saga
sagaMiddleware.run(rootSaga);

Constructors

Options({Map? context, Channel? channel, SagaMonitor? sagaMonitor, OnErrorHandler? onError, List<EffectMiddlewareHandler>? effectMiddlewares})
Creates an instance of a middleware Options

Properties

channel Channel?
A channel is an object used to send and receive messages between tasks. Preferably you should use StdChannel here.
getter/setter pair
context Map?
Initial value of the saga's context.
getter/setter pair
effectMiddlewares List<EffectMiddlewareHandler>?
Allows you to intercept any effect, resolve it on your own and pass to the next middleware.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
onError OnErrorHandler?
If provided, the middleware will call it with uncaught errors from Sagas. useful for sending uncaught exceptions to error tracking services.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sagaMonitor SagaMonitor?
If a Saga Monitor is provided, the middleware will deliver monitoring events to the monitor.
getter/setter pair

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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