Amy Blankenship
1 min readApr 24, 2020

--

It’s actually not unexpected that a promise that has already resolved will simply return the value it previously resolved to — that’s what the promise API said it should do. But I find it hard to think of a place where you’d cancel the Signal and would also not have a reference to that signal where you need to decide what to do with the result of the signal (in which case you can just check there if the signal was cancelled).

The purpose of being able to cancel is to prevent calls that either have not been made yet or are in progress but you no longer need the results of from continuing (like you just sent 50 calls and only 10 of them have returned before the user navigates away).

If you’re using Redux, redux-sagas have a nice way of handing cancellation of a signal (it sets cancelled on the entire generator).

--

--

Amy Blankenship
Amy Blankenship

Written by Amy Blankenship

Full Stack developer at fintech company. I mainly write about React, Javascript, Typescript, and testing.

No responses yet