ExtraArgumentThunkMiddleware<S, A> class

The ExtraArgumentThunkMiddleware works exactly like the normal thunkMiddleware with one difference: It injects the provided "extra argument" into all Thunk functions.

Example

// First, create a quick reducer
final reducer = (String state, action) => action is String ? action : state;

// Next, apply the `ExtraArgumentThunkMiddleware` to the Store. In this
// case, we want to provide an http client to each thunk function.
final store = new Store<String>(
  reducer,
  middleware: [ExtraArgumentThunkMiddleware(http.Client())],
 );

// Create a `ThunkActionWithExtraArgument`, which is a fancy name for a
// function that takes in a Store and the extra argument provided above
// (the http.Client).
Future<void> fetchBlogAction(Store<String> store, http.Client client) async {
  final response = await client.get('https://jsonplaceholder.typicode.com/posts');

  store.dispatch(response.body);
}

Constructors

ExtraArgumentThunkMiddleware(A extraArgument)
Create a ThunkMiddleware that will inject an extra argument into every thunk function

Properties

extraArgument → A
An Extra argument that will be injected into every thunk function.
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

call(Store<S> store, dynamic action, NextDispatcher next) → dynamic
A Middleware function that intercepts a dispatched action
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