Im trying to use the delay functionality but I get an error that delay is not a function.
Straight from the docs:
import { race, call, put, delay } from 'redux-saga/effects'
function* fetchPostsWithTimeout() {
const {posts, timeout} = yield race({
posts: call(fetchApi, '/posts'),
timeout: delay(1000)
})
if (posts)
yield put({type: 'POSTS_RECEIVED', posts})
else
yield put({type: 'TIMEOUT_ERROR'})
}
Such a powerful & elegant tool as Redux-Saga, a Redux side effect manager, is said to be deprecated, and no longer being maintained, starting from Jan 27, 2021.
Calling them spawns a saga on each action dispatched to the Store that matches pattern. takeEvery: The most common takeEvery function is very similar to redux-thunk in its behaviour and methodology. It's basically a wrapper for yield take of a pattern or channel and yield fork .
Redux Saga is a middleware library used to allow a Redux store to interact with resources outside of itself asynchronously. This includes making HTTP requests to external services, accessing browser storage, and executing I/O operations. These operations are also known as side effects.
I suspect the reason for this is because the docs were recently updated for redux-saga v1.0.0
. This is important because previously (in 0.x versions you are probably using) it wasn't effect but just a helper.
In the 0.x version you should import it as:
import {delay} from 'redux-saga'
This delay function will return a promise.
In the 1.0.0 version you can use it as mentioned in the docs.
import {delay} from 'redux-saga/effects'
This delay is an effect creator and will return an effect object.
For more info about the v1 release see https://github.com/redux-saga/redux-saga/releases/tag/v1.0.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With