I need to make a redux-saga call every 2 seconds. How to implement it with such a code:
export function* getMyMeetings(action:any) {
let {auth_uid} = action;
const meetings = yield call(
getData,
'get',
`api/notes/by-user/${auth_uid}`
);
yield put(putMeetings(meetings));
}
I know that I have to do this with delay
but I can't understand how to do it. Could someone help with this?
Thanks
I would do something like this
export function* getMyMeetings(action:any) {
let {auth_uid} = action;
const meetings = yield call(
getData,
'get',
`api/notes/by-user/${auth_uid}`
);
yield put(putMeetings(meetings));
yield delay(2000); // 2 seconds sleep
yield call(getMyMeetings, actions); // Recursive function call, first parameter is the Saga to call, the others parameters are the ones binding to this Saga function
}