-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(registration/handAnimation): stop looping after unmount
Clearing the timeout is not useful, it will have already fired. The problem is with the recursive callbacks, which must be broken with a flag
- Loading branch information
Showing
1 changed file
with
11 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92984eb
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 was under the impression that clearTimeout clears all the memory associated with the callback and so de-allocates the animation stuff, but there's a pretty good chance I'm wrong, and also the flag method is much clearer to understand/read, noice
92984eb
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.
clearTimeout
would only remove the timeout from the queue, if it hasn't already been executed. And that timeout was just the one that starts the firstpulse
. The callback which is passed to.start
though is used internally and scheduled in a different manner, there are definitely other references to it and wouldn't get garbage collected (and anyway most probably the initial timeout will have executed anyway since the delay was0
:D)