Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to cancel "all"? #988

Closed
gajus opened this issue May 12, 2017 · 2 comments
Closed

How to cancel "all"? #988

gajus opened this issue May 12, 2017 · 2 comments

Comments

@gajus
Copy link
Contributor

gajus commented May 12, 2017

I have the following construct:

export default function *(): Generator<*, *, *> {
  while (yield take(SET_START)) {
    const allTasks = yield all([
      fork(createRequestRoutine(GET_MOVIES, getMoviesRemote, setMovies, setError)),
      fork(watchNewSearchCriteria)
    ]);

    yield take(SET_STOP);

    yield cancel(allTasks);
  }
}

Attempting to yield cancel(allTasks) produces an error:

uncaught at rootSaga
at effects
Error: cancel(task): argument [object Object],[object Object] is not a valid Task object
(HINT: if you are getting this errors in tests, consider using createMockTask from redux-saga/utils)

It is not clear from the documentation how to cancel tasks forked using all.

@Andarist
Copy link
Member

Should work with yield cancel(...allTasks) or yield all(allTasks.map(task => cancel(task))). We'll try to add some docs info later.

@gajus
Copy link
Contributor Author

gajus commented May 12, 2017

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants