Advertisement
Guest User

Untitled

a guest
Dec 6th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default class Timer {
  2.     elementId;
  3.     element;
  4.  
  5.     constructor(elementId) {
  6.         this.elementId = elementId;
  7.         this.element = document.querySelector(elementId);
  8.  
  9.         if (!this.element) {
  10.             throw new Error(`[Timer] Couldn't find element with id ${elementId}`)
  11.        }
  12.  
  13.        this._interval = setInterval(() => {
  14.            this.element.innerText = '2:00'
  15.        }, 1000)
  16.    }
  17.  
  18.    stop() {
  19.        console.log('stop timer!', this.elementId);
  20.        clearInterval(this._interval);
  21.    }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement