I start a timer for the stopwatch. I react the component when the START action is sent:
import 'babel-polyfill' import { call, put } from 'redux-saga/effects' import { delay, takeEvery, takeLatest } from 'redux-saga' import { tick, START, TICK, STOP } from './actions' const ONE_SECOND = 1000 export function * timerTickWorkerSaga (getState) { yield call(delay, ONE_SECOND) yield put(tick()) } export default function * timerTickSaga () { yield* takeEvery([START, TICK], timerTickWorkerSaga) yield* takeLatest(STOP, cancel(timerTickWorkerSaga)) }
I have a problem stopping the saga when a STOP action STOP sent from my component. I tried using the cancel and cancelled effects from my working saga:
if(yield(take(STOP)) { yield cancel(timerTickWorkerSaga) }
as well as the approach in the first block of code where I try to stop the saga from the surveillance service.
javascript redux redux-saga
vamsiampolu
source share