Created
November 22, 2020 15:37
-
-
Save vyuvalv/983b01ec212fdb098bf050a4519df696 to your computer and use it in GitHub Desktop.
setInterval
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
this.speed = 500; | |
interval; | |
// activate the loop | |
onPlay() { | |
this.interval = window.setInterval(() => { | |
// Do Something | |
this.nextGeneration(); | |
}, this.speed); | |
} | |
// Stop the infinite loop | |
onStop() { | |
window.clearInterval(this.interval); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment