import { delay } from 'redux-saga' ; import { put , select } from 'redux-saga/effects' ; import { RootState } from '../types' ; import { SearchRequest , searchRequestContinuous } from '../actions/search' ; import { ScheduleNextSearch } from '../actions/scheduler' ; export function * searchAfterDelay ( action ) { yield delay ( action . time . valueOf ( ) - Date . now ( ) ) ; const searchingActive = yield select ( ( state ) => state . searchingActive ) ; if ( searchingActive ) { yield put < SearchRequest > ( searchRequestContinuous ( ) ) ; } }