SHARE
TWEET

Untitled

a guest Dec 6th, 2018 74 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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top