Created
July 30, 2019 06:33
-
-
Save jesperlandberg/824637624d8e14c6f8e51173d6fa1e70 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| startLoop = () => { | |
| this.loop = setInterval(this.someMethod, 5000) | |
| } | |
| clearLoop = () => { | |
| clearInterval(this.loop) | |
| } | |
| onFocus = () => { | |
| this.startLoop() | |
| } | |
| onBlur = () => { | |
| this.clearLoop() | |
| } | |
| addListeners = () => { | |
| window.addEventListener('focus', this.onFocus) | |
| window.addEventListener('blur', this.onBlur) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment