Non blocking async call effects.
$ npm install @floxjs/fork
import forkEffect, {fork, join} from '@floxjs/fork'
const store = applyMiddleware(flo(), forkEffect)(createStore)(reducer, {})
function * child () {
yield delay(5)
return 'foo'
}
store.dispatch(function * () {
const task = yield fork(child)
// do some things
yield join(task) // => 'foo'
})
Action creator.
fn
- function, generator, or iterator to fork
Returns: a task
Action creator.
task
- task to block on
Returns: result of task
Action creator. Throws error in running task with message: 'TaskCanceled'.
task
- task to cancel
Runs tasks. Used internally by koax.
dispatch
- dispatch function
Returns: dispatch
Returns: whether task is running
Returns: the result of the task
Returns: the error thrown by the task
###task.cancel() Cancels task
MIT