Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

fix($timeout.$flush): make $flush follow the timeline #5420

Closed
wants to merge 1 commit into from

Conversation

lgalfaso
Copy link
Contributor

Make the mock $timeout.$flush follow the timeline when the function
being calls $timeout

@petebacondarwin
Copy link
Contributor

@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);
Copy link
Contributor

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?

Copy link
Contributor Author

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
@lgalfaso
Copy link
Contributor Author

@petebacondarwin Thanks for the comment, updated the commit message and hope that it is now clear

@petebacondarwin
Copy link
Contributor

This is very vaguely related to #13183. It would be interesting to solve both at once...

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request May 27, 2016
…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
petebacondarwin pushed a commit that referenced this pull request May 27, 2016
…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
IgorMinar pushed a commit that referenced this pull request Jun 20, 2016
…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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants