Re:Cancelable Promises: Why was this proposal withdrawn?
by fareesh on Monday December 19, 2016 @09:20AM
(#13211510)
What's a good existing way to deal with this use-case? Is there a useful library that wraps setTimeout / other logic to determine the quality of a user's internet connection in case of very poor connectivity (2G etc) ?
[ Parent
| on HN ]
Re:Cancelable Promises: Why was this proposal withdrawn?
by jdesjean on Monday December 19, 2016 @09:41AM
(#13211641)
The way to handle this case is to use Promise.race with 2 promises. The first promise is your logic. The second promise is rejected after a timeout. For more detail read the section "never calling the callback" from "you don't know js" book on "async" in chapter 3
https://github.com/getify/You-Dont-Know-JS/blob/master/async...
Re:Cancelable Promises: Why was this proposal withdrawn?
by soft_dev_person on Monday December 19, 2016 @10:37AM
(#13212018)
But that doesn't actually cancel the request, and thusly the data is downloaded anyway? Or am I missing something?
Re:Cancelable Promises: Why was this proposal withdrawn?
by fareesh on Monday December 19, 2016 @09:46AM
(#13211673)
Thanks I'll check it out
Re:Cancelable Promises: Why was this proposal withdrawn?
by fermuch on Monday December 19, 2016 @09:38AM
(#13211625)
In react native, NetInfo has an api to detect network changes and I use that to stop all my setIntervals and start again with a different set of args, including wait time before calling again.