Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export default class Timer {
- elementId;
- element;
- constructor(elementId) {
- this.elementId = elementId;
- this.element = document.querySelector(elementId);
- if (!this.element) {
- throw new Error(`[Timer] Couldn't find element with id ${elementId}`)
- }
- this._interval = setInterval(() => {
- this.element.innerText = '2:00'
- }, 1000)
- }
- stop() {
- console.log('stop timer!', this.elementId);
- clearInterval(this._interval);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement