Same as call([context, fn], ...args) but supports passing a fn as string.
Useful for invoking object's methods, i.e.
yield call([localStorage, 'getItem'], 'redux-saga')
Same as call([context, fn], ...args) but supports passing context and
fn as properties of an object, i.e.
yield call({context: localStorage, fn: localStorage.getItem}, 'redux-saga').
fn can be a string or a function.
Same as call([context, fn], ...args) but supports passing context and
fn as properties of an object, i.e.
yield call({context: localStorage, fn: localStorage.getItem}, 'redux-saga').
fn can be a string or a function.
Creates an Effect description that instructs the middleware to call the function
fnwithargsas arguments.Notes
fncan be either a normal or a Generator function.The middleware invokes the function and examines its result.
If the result is an Iterator object, the middleware will run that Generator function, just like it did with the startup Generators (passed to the middleware on startup). The parent Generator will be suspended until the child Generator terminates normally, in which case the parent Generator is resumed with the value returned by the child Generator. Or until the child aborts with some error, in which case an error will be thrown inside the parent Generator.
If
fnis a normal function and returns a Promise, the middleware will suspend the Generator until the Promise is settled. After the promise is resolved the Generator is resumed with the resolved value, or if the Promise is rejected an error is thrown inside the Generator.If the result is not an Iterator object nor a Promise, the middleware will immediately return that value back to the saga, so that it can resume its execution synchronously.
When an error is thrown inside the Generator, if it has a
try/catchblock surrounding the currentyieldinstruction, the control will be passed to thecatchblock. Otherwise, the Generator aborts with the raised error, and if this Generator was called by another Generator, the error will propagate to the calling Generator.