4 ms·
A bit off topic but in the context of promises and Angular, I love the ability to set a set a promise for the timeout parameter. This is super valuable 'cause i
by kin 12y ago
A bit off topic but in the context of promises and Angular, I love the ability to set a set a promise for the timeout parameter. This is super valuable 'cause it lets me manually cancel any request instead of waiting for a response or timing out via time.
- aikah 12y ago> I love the ability to set a set a promise for the timeout parameter. please explain .
- Arnavion 12y agoI assume the grandparent is talking about functions in Angular that take in a numeric timeout parameter and wants them to take in Promises instead, so he can reject the promises to signal that he wants to cancel the operation. Kinda like CancellationToken in .Net, I guess.
- bengarvey 12y agoYou can pass a promise into an $http request as a parameter. If you hold on to this promise and resolve it before the request returns, it cancels the request. https://docs.angularjs.org/api/ng/service/$http https://docs.angularjs.org/api/ng/service/$http
- inglor 12y agoIf you'd like - we have a $q decorator in our code base that adds `.timeout` to promises and allows you to cancel them if the timeout expires (just like in Bluebird, from before we used Bluebird with Angular). Let me know if that's interesting to you and I'll put it on GH.
- andyzweb 12y agoI would be interested in seeing it posted~