During development, use this error observer if you want all errors to be
shown to the user in a dialog, not only UserExceptions. In more detail:
This will wrap all errors into UserExceptions, and put them all into the
error queue. Note that errors which are NOT originally UserExceptions will
still be thrown, while UserExceptions will still be swallowed.
Events are one-time notifications stored in the Redux state, used to trigger
side effects in widgets such as showing dialogs, clearing text fields, or
navigating to new screens.
Connects a Logger to the Redux Store.
Every action that is dispatched will be logged to the Logger, along with the new State
that was created as a result of the action reaching your Store's reducer.
The ModelObserver is rarely used. It's goal is to observe and troubleshoot the model changes
causing rebuilds. While you may subclass it to implement its observe method, usually you can
just use the provided DefaultModelObserver to print the StoreConnector's ViewModel to the
console.
One or more StateObservers can be set during the Store creation. Those observers are
called for all dispatched actions, right after the reducer returns. That happens before the
after() method is called, and before the action's wrapError() and the global wrapError()
methods are called.
During tests, use this error observer if you want all errors to be thrown,
and not swallowed, including UserExceptions. You should probably use this
in all tests that you don't expect to throw any errors, including
UserExceptions.
Each state passed in the Vm.equals parameter in the in view-model will be
compared by equality (==), unless it is of type VmEquals, when it will be
compared by the VmEquals.vmEquals method, which by default is a comparison
by identity (but can be overridden).
WaitAction and Wait work together to help you create boolean flags that
indicate some process is currently running. For this to work your store state
must have a Wait field named wait, and then:
You may globally wrap the reducer to allow for some pre or post-processing.
Note: if the action also have a ReduxAction.wrapReduce method, this global
wrapper will be called AFTER (it will wrap the action's wrapper which wraps
the action's reducer).
Mixin AbortWhenNoInternet can be used to check if there is internet when
you run some action that needs it. If there is no internet, the action will
abort silently, as if it had never been dispatched.
Mixin CheckInternet can be used to check if there is internet when you
run some action that needs internet connection. Just add with CheckInternet
to your action. For example:
Mixin Debounce delays the execution of a function until after a certain
period of inactivity. Each time the debounced function is called,
the period of inactivity (or wait time) is reset.
Mixin Fresh lets you treat the result of an action as fresh for a
given time period. While the information is fresh, repeated dispatches of
the same action (or other actions with the same "fresh-key") are skipped,
because that information is assumed to still be valid in the state.
Mixin NonReentrant can be used to abort the action in case the action
is still running from a previous dispatch. Just add with NonReentrant
to your action. For example:
Mixin OptimisticCommand is for actions that represent a command.
A command is something you want to run on the server once per dispatch.
Typical examples are:
Mixin OptimisticSync is designed for actions where user interactions
(like toggling a "like" button) should update the UI immediately and
send the updated value to the server, making sure the server and the UI
are eventually consistent.
Mixin ServerPush should be used by actions that put, in the store state,
values that were received by server-push, via WebSockets, Server-Sent
Events (SSE), Firebase, etc.
Mixin Throttle ensures the action will be dispatched at most once in the
specified throttle period. It acts as a simple rate limit, so the action
does not run too often.
Mixin UnlimitedRetryCheckInternet can be used to check if there is
internet when you run some action that needs it. If there is no internet,
the action will abort silently, and then retry the reduce method
unlimited times, until there is internet. It will also retry if there
is internet but the action failed.
This extension allows you to write dispatch() instead of
context.dispatch() inside the State of a StatefulWidget. It
also works for dispatchAndWait(), dispatchAll(), dispatchAndWaitAll(),
dispatchSync(), isWaiting(), isFailed(), exceptionFor(), and
clearExceptionFor().
This extension allows you to write dispatch() instead of
context.dispatch() inside a StatelessWidget. It also works for
dispatchAndWait(), dispatchAll(), dispatchAndWaitAll(),
dispatchSync(), isWaiting(), isFailed(), exceptionFor(), and
clearExceptionFor().
cache1state<Result, State1>(Result Function()f(State1))
→ Result Function() Function(State1)
Cache for 1 immutable state, and no parameters.
cache1state_0params_x<Result, State1, Extra>(Result Function()f(State1, Extra))
→ Result Function() Function(State1, Extra)
Cache for 1 immutable state, no parameters, and some extra information. This is the same
as cache1state but with an extra information. Note: The extra information is not used in
any way to decide whether the cache should be used/recalculated/evicted. It's just passed down
to the f function to be used during the result calculation.
cache1state_1param<Result, State1, Param1>(Result Function(Param1)f(State1))
→ Result Function(Param1) Function(State1)
Cache for 2 immutable states, no parameters, and some extra information. This is the same
as cache1state but with an extra information. Note: The extra information is not used in
any way to decide whether the cache should be used/recalculated/evicted. It's just passed down
to the f function to be used during the result calculation.
Cache for 3 immutable states, no parameters, and some extra information.This is the same
as cache1state but with an extra information. Note: The extra information is not used in
any way to decide whether the cache should be used/recalculated/evicted. It's just passed down
to the f function to be used during the result calculation.
When the Event class was created, Flutter did not have any class named
Event. Now there is. For this reason, this typedef allows you to use Evt
instead. You can hide one of them, by importing AsyncRedux like this:
import 'package:async_redux/async_redux.dart' hide Event;
or
import 'package:async_redux/async_redux.dart' hide Evt;
A function that will be run when the StoreConnector is removed from the Widget Tree.
It is run in the State.dispose method.
This can be useful for dispatching actions that remove stale data from your State tree.
A function that will be run when the StoreConnector is initialized (using
the State.initState method). This can be useful for dispatching actions
that fetch data for your Widget when it is first displayed.
A function that will be run after the Widget is built the first time.
This function is passed the store and the initial Model created by the vm
or the converter function. This can be useful for starting certain animations,
such as showing Snackbars, after the Widget is built the first time.
A function that will be run on state change, before the build method.
This function is passed the Model, and if distinct is true,
it will only be called if the Model changes.
This is useful for making calls to other classes, such as a
Navigator or TabController, in response to state changes.
It can also be used to trigger an action based on the previous state.
A test of whether or not your converter or vm function should run in
response to a State change. For advanced use only.
Some changes to the State of your application will mean your converter
or vm function can't produce a useful Model. In these cases, such as when
performing exit animations on data that has been removed from your Store,
it can be best to ignore the State change while your animation completes.
To ignore a change, provide a function that returns true or false. If the
returned value is false, the change will be ignored.
If you ignore a change, and the framework needs to rebuild the Widget, the
builder function will be called with the latest Model produced
by your converter or vm functions.
If an action throws an AbortDispatchException the action will abort immediately
(But note the after method will still be called no mather what).
The action status will be isDispatchAborted: true.
The ConnectionException is a type of UserException that warns the user when the connection
is not working. Use ConnectionException.noConnectivity for a simple version that warns the
users they should check the connection. Use factory create to give more complete messages,
indicating the host that is having problems.