Asynchronous reducer pipelines using callbags.
Try it now on CodeSandbox.
Install
npm install react-callbag --save
Pipeline operator
If you don't have the pipeline operator you can use the pipe function. foo |> bar()
would instead be pipe(foo, bar())
.
Basic usage
; const reducers = "SUBTRACT" count: statecount - amount "ADD" count: statecount + amount "MULTIPLY" count: statecount * multiplier ; const pipeline = actions |> |> ;
<Subject => state send <div> <button =>Remove 1</button> <button =>Add 1</button> <button =>Multiply by 2</button> <div>statecount</div> </div> </Subject>
Debouncing example
; const pipeline = actions |> |> |> ;
Further reading
- Callbag basics
- Callbag wiki
- Why we need callbags, by André Staltz