feature request: parallels
willin opened this issue · 2 comments
willin commented
a bit like fxIf
, pass in a list(array) of actions.
export const runOneByOne = () => state => parallels([
action('set', {loading: true}),
// async action like http
action('makeRequest'),
// sync action like set
action('handleResponse'),
// data filter
action('updateState'),
action('set', {loading: false})
]);
each one should be fired after previous one done.
okwolf commented
@willin action fx don't really have a concept of being "done". Some other fx do take an action parameter to act as a callback after some side effect (timer/network request/etc) is completed.
If you just want to call each of those actions, return an array of them. Your makeRequest
action would be responsible for chaining the call to handleResponse
that could update the state and set
your loading
to false
:
const actions = {
set: state => state,
makeRequest: () => [
action("set", { loading: true }),
http("https://...", "handleResponse")
],
handleResponse: data => action("set", { loading: false, data })
}