My main goal is to postpone the counter until it starts.
Imagine a timeout disables 'n' to '0' and then fires an event, but it can be reset asynchronously to "n" every time something happens.
I tried to achieve this using 'promises' with $ q.
I tried to add dynamically new promises with a timeout in the new delay chain.
But before reaching this goal, I could not even knit new promises.
Example:
var d1 = $q.defer(); var d2 = $q.defer(); d1.promise.then(function(data) { return 'd1' + data; }); d2.promise.then(function(data) { return 'd2' + data; }); var t = $q.all([d1.promise]); t.then(function(data) { console.log(data); }); $timeout(function() { d1.resolve("1000"); }, 1000); $timeout(function() { t.then(function() { d2.resolve("800"); }); }, 800);
It only outputs: ["1000"] instead of ["1000", "800"]
My search:
stack overflow.squite
angular-promise-tracker I canβt understand this code, how it behaves exactly for what I need. But this is done for something else.
source share