reversible flow for building robust application with javascript
- explicit(serial/concurrent) flow construction
- multi step rollback made easy
- works with both sync and async(returns promise) functions
var reverflow = require("reverflow/legacy");
const {serial} = require('reverflow');
serial(x => x + 1, x => x * 2)(1).then(console.log);
4
const {serial, concurrent} = require('reverflow');
serial(concurrent(serial(x => x + 1, x => x * 2),
x => x * 3),
([x, y]) => x + y)(1).then(console.log);
7
when C
fails, B
should be rolled back, then A
.
reverflow does this auotmatically, you can make an operation
rollbackable with the rollbackable
function
import {serial, rollbackable} from reverflow
serial(rollbackable(A, undoA),
rollbackable(B, undoB),
rollbackable(C, undoC))(input);
when C
fails, B
and D
should be rolled back, then A
.
import {rollbackable, serial, concurrent} from reverflow
serial(rollback(A, undoA), concurrent(rollbackable(B, undoB),
rollbackable(C, undoC),
rollbackable(D, undoD)))(input);
rollbackable(input => save({id: uuid.v4()}), ({id}) => remove(id));
serial(a,b,c)
is equivelant to serial([a, b, c])