Getting Started

Install Aquaman from NPM:

npm i -S aquaman-redux

Aquaman provides Redux middleware.

import { createStore } from 'redux';
import { applyAquamanAndMiddleWare } from 'aquaman-redux';

import reducer from './reducer';
import aquamanFlows from './aquamanFlows';
import { mapReduxToConfig } from './aquamanConfig';

const createStoreWithMiddleware = composeEnhancers(
    applyAquamanAndMiddleware(aquamanFlows, mapReduxToConfig)(otherMiddleware);
);

export const store = createStoreWithMiddleware(reducer);

You'll need to provide mapReduxToConfig and your aquamanFlows.

Aquaman provides four actions creators for your connected components to interact with flows:

  1. aquamanNext

  2. aquamanPrevious

  3. aquamanClose

  4. aquamanForceFlow

aquamanNext

function aquamanNext(data?: any): AquamanNextAction;

aquamanNext is your primary action creator for Aquaman. When dispatched, it causes your flow to step forward.

It optionally receives an argument, which can be used for branching, or for passing data to the next step.

aquamanPrevious

function aquamanPrevious(): AquamanPreviousAction;

Aquaman allows you to have back buttons in your components that will allow the user to traverse backwards through a flow. Dispatch aquamanPrevious to do so.

aquamanClose

function aquamanClose(): AquamanCloseAction;

Dispatching aquamanClose will exit out of whatever flow is active before it's completed. Attach this to a close button so users can end the flow early.

aquamanForceFlow

function aquamanForceFlow(key: string, soft?: boolean): AquamanForceFlowAction;

aquamanForceFlow will allow you to activate a particular flow from a user action (such as clicking a button) rather than from entering a particular state. The key here is defined in your flow table and will be unique to the action series.

By default, aquamanForceFlow will stop whatever flow the user is in and start the selected one. You can optionally pass a second argument soft to prevent the forced flow from being started if there is another flow in progress.

Last updated