Configuration
mapReduxToConfig
You need to provide a mapReduxToConfig
function to Aquaman middleware to handle some special cases.
mapReduxToConfig
has two parameters, your Redux store, and the store's dispatch function. This will allow it to access the current state of the application and dispatch new actions.
mapReduxToConfig
needs to return an object that implements five methods:
onEndFlow
onStep
shouldStartFlow
onWillChooseFlow
functionMap
onEndFlow
onEndFlow
gets triggered when a flow is completed or closed.
You can make the function async
so that you can wait on persistent storage updates before Aquaman starts checking for flows again.
Aquaman will ensure the same flow is not shown again during the same app lifecycle, but you'll likely want to persist that the user has seen this flow so that it doesn't get shown again in future sessions. You should use the flowId to persist that to prevent the flow from being shown again.
onStep
onStep
is called after each aquamanNext
dispatch. It can be useful to close all modals/tooltips if they're open, so that logic does not need to be included in your action series.
shouldStartFlow
shouldStartFlow
is useful to prevent flows from starting until some condition has been met, such as your application being fully loaded and rendered. Defaults to true
.
onWillChooseFlow
onWillChooseFlow
provides you with an opportunity to override flows, probably with data from a separate service. This will be called once a condition for a flow is met. That selected flow object will be passed to the function, allowing you to use its id to find a corresponding action series to override it with.
functionMap
Action series are meant to be fully serializable so that you can define them on separate services. Since functions are not serializable, you cannot pass them via a JSON object. functionMap
allows you to use functions in your web application that will get called from a serialized action series.
mutuallyExclusiveFlows
An array of arrays of flowIds. If a flow is shown during the lifecycle of an app, none of the other flows in the same "mutually exclusive" array will be shown.
In the example below, if a flow with flowId5
is shown, then flows with flowId6
can't be shown until the app restarts.
Example
Last updated
Was this helpful?