1👍
✅
toggleInterval() {
let handler;
this.switcher = !this.switcher;
if (this.switcher) {
handler = () => {
console.log('This is first interval');
};
} else {
handler = () => {
console.log('This is first interval');
};
}
clearInterval(this.intervalId);
this.intervalId = setInterval(handler, 1000);
},
Source:stackexchange.com