Serialization

Almost any kind of flow you want to create in your app can be represented in JSON form with Aquaman. This means that you can pass the action series from an external service (perhaps an experiment service that does machine learning?) to your application.

Redux actions are plain objects, which are easy to serialize. Arrays of plain objects are also easy to serialize. Branching and functions are a little trickier, but easy enough.

Branch

Aquaman's branch function just creates a Branch object, which will look as follows:

const branchObj = {
    __BRANCH__: true,
    0: [step1, step2],
    1: [step3, step4],
    2: [step3, step2, step4],
};

You need to add the __BRANCH__ property to identify it as a branch object, and then your keys will correspond to value passed to aquamanNext to pick the correct leaf flow.

Functions

Functions can't be serialized. If you configure a function map, you'll be able to use a function in your multi-action step. You'll do this with a MappedFunction object:

const mappedFunctionObj = {
    __Aquaman_FUNCTION__: true,
    functionName: 'track',
    args: ['completed_onbarding'],
};

When this object is reached, Aquaman will look up the functionName in your function map, and spread the args array into that corresponding function.

END_FLOW

The underlying value for FORCE_END_MULTISTEP is Aquaman_FORCE_END_MULTISTEP . Use it to end a multi-action step that doesn't show a component that the user can step out of.

Last updated