-
Notifications
You must be signed in to change notification settings - Fork 27.5k
fix($timeout.$flush): make $flush follow the timeline #5420
Conversation
@lgalfaso - thanks for this. Can you clarify the commit the message. "Make timeout follow the timeline" is a bit vague and doesn't really explain what you are fixing. I guess from looking at the code, that the problem is that the current implementation doesn't take into account new timeouts that are added "out of order". Is that correct? |
var count1 = 0, count2 = 0; | ||
var iterate1 = function() { | ||
count1++; | ||
$timeout(iterate1, 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that we don't need to worry about self-referencing timeouts being left around since they are mocked up anyway?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all mock code, if there is a need to clean this up, please let me know
Fix an issue when flushing a $timeout function and, this function, calls $timeout once again. When this is the case, the new timeout function should be called at the thoerical `now` of when the function was called plus the new period
@petebacondarwin Thanks for the comment, updated the commit message and hope that it is now clear |
02dc2aa
to
fd2d6c0
Compare
cad9560
to
f294244
Compare
e8dc429
to
e83fab9
Compare
4dd5a20
to
998c61c
Compare
This is very vaguely related to #13183. It would be interesting to solve both at once... |
…lbacks If a $timeout handler calls $timeout itself, this new $timeout should be added to the mock deferred queue with a "now" time based on when the original handler was triggered. Previously it was being added with a now time of when the `$timeout.flush` method was originally called. Closes angular#5420
…lbacks If a $timeout handler calls $timeout itself, this new $timeout should be added to the mock deferred queue with a "now" time based on when the original handler was triggered. Previously it was being added with a now time of when the `$timeout.flush` method was originally called. Closes #5420 Closes #14686
…lbacks If a $timeout handler calls $timeout itself, this new $timeout should be added to the mock deferred queue with a "now" time based on when the original handler was triggered. Previously it was being added with a now time of when the `$timeout.flush` method was originally called. Closes #5420 Closes #14686
Make the mock $timeout.$flush follow the timeline when the function
being calls $timeout