import { fork , take , select , put } from 'redux-saga/effects' ; import { Counter , Todos } from '../store' ; import { StoreST } from '../store' ; function * mapTodosCountToCounter ( ) { const { setTodoCount } = Counter . creators ; while ( true ) { yield take ( Todos . types . addTodo ) ; const storeState = yield select ( ) ; yield put ( setTodoCount ( storeState . todos . items . length ) ) ; } } export function * rootSaga ( ) { yield fork ( mapTodosCountToCounter ) ; }