{"version":3,"file":"interval-controller-CPNwUoK6.js","sources":["../src/controllers/interval-controller.ts"],"sourcesContent":["import { ReactiveController, ReactiveControllerHost } from 'lit';\r\n\r\nexport class IntervalController implements ReactiveController {\r\n host: ReactiveControllerHost;\r\n\r\n //value = new Date();\r\n timeout: number;\r\n private _timerID?: number;\r\n private _handler: () => void;\r\n\r\n constructor(host: ReactiveControllerHost, handler: () => void, timeout = 1000) {\r\n (this.host = host).addController(this);\r\n this.timeout = timeout;\r\n this._handler = handler;\r\n }\r\n startInterval() {\r\n if (this._timerID === undefined) {\r\n //console.log('interval started')\r\n // Start a timer when the host is connected\r\n this._timerID = window.setInterval(() => {\r\n this._handler()\r\n // this.value = new Date();\r\n // // Update the host with new value\r\n // this.host.requestUpdate();\r\n }, this.timeout);\r\n }\r\n }\r\n stopInterval() {\r\n //console.log('interval stopped')\r\n // Clear the timer when the host is disconnected\r\n window.clearInterval(this._timerID);\r\n this._timerID = undefined;\r\n }\r\n\r\n hostConnected() {\r\n //this.startInterval();\r\n }\r\n hostDisconnected() {\r\n this.stopInterval();\r\n }\r\n}"],"names":["IntervalController","host","handler","timeout"],"mappings":"AAEO,MAAMA,EAAiD;AAAA,EAQ5D,YAAYC,GAA8BC,GAAqBC,IAAU,KAAM;AAC7E,KAAC,KAAK,OAAOF,GAAM,cAAc,IAAI,GACrC,KAAK,UAAUE,GACf,KAAK,WAAWD;AAAA,EAAA;AAAA,EAElB,gBAAgB;AACV,IAAA,KAAK,aAAa,WAGf,KAAA,WAAW,OAAO,YAAY,MAAM;AACvC,WAAK,SAAS;AAAA,IAAA,GAIb,KAAK,OAAO;AAAA,EACjB;AAAA,EAEF,eAAe;AAGN,WAAA,cAAc,KAAK,QAAQ,GAClC,KAAK,WAAW;AAAA,EAAA;AAAA,EAGlB,gBAAgB;AAAA,EAAA;AAAA,EAGhB,mBAAmB;AACjB,SAAK,aAAa;AAAA,EAAA;AAEtB;"}