/** * Root saga manages watcher lifecycle */ export function* githubRepoFormSaga() { // Watches for loadRepos actions and calls getRepos when one comes in. // By using `takeLatest` only the result of the latest API call is applied. // It returns task descriptor (just like fork) so we can continue execution // It will be cancelled automatically on component unmount yield takeLatest(actions.loadRepos.type, getRepos); }
describe('githubRepoFormSaga Saga', () => { const githubRepoFormIterator = githubRepoFormSaga(); it('should start task to watch for loadRepos action', () => { const takeLatestDescriptor = githubRepoFormIterator.next().value; expect(takeLatestDescriptor).toEqual( takeLatest(slice.actions.loadRepos.type, getRepos), ); }); });
/** * Root saga manages watcher lifecycle */ export function* githubRepoFormSaga() { // Watches for loadRepos actions and calls getRepos when one comes in. // By using `takeLatest` only the result of the latest API call is applied. // It returns task descriptor (just like fork) so we can continue execution // It will be cancelled automatically on component unmount yield takeLatest(actions.loadRepos.type, getRepos); }
describe('githubRepoFormSaga Saga', () => { const githubRepoFormIterator = githubRepoFormSaga(); it('should start task to watch for loadRepos action', () => { const takeLatestDescriptor = githubRepoFormIterator.next().value; expect(takeLatestDescriptor).toEqual( takeLatest(slice.actions.loadRepos.type, getRepos), ); }); });