@lightningjs/blits 1.29.1 → 1.29.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ _28 may 2025_
4
+
5
+ ## v1.29.2
6
+
7
+ - Added end of life flag to prevent timers, intervals and listeners to be registered after component destroy
8
+
3
9
  _22 may 2025_
4
10
 
5
11
  ## v1.29.1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "1.29.1",
3
+ "version": "1.29.2",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -29,6 +29,8 @@ export default {
29
29
  },
30
30
  $listen: {
31
31
  value: function (event, callback, priority = 0) {
32
+ // early exit when component is marked as end of life
33
+ if (this.eol === true) return
32
34
  eventListeners.registerListener(this, event, callback, priority)
33
35
  },
34
36
  writable: false,
@@ -52,6 +52,7 @@ export default {
52
52
  },
53
53
  destroy: {
54
54
  value: function () {
55
+ this.eol = true
55
56
  this.lifecycle.state = 'destroy'
56
57
  this.$clearTimeouts()
57
58
  this.$clearIntervals()
@@ -20,6 +20,8 @@ import symbols from '../../lib/symbols.js'
20
20
  export default {
21
21
  $setTimeout: {
22
22
  value: function (fn, ms, ...params) {
23
+ // early exit when component is marked as end of life
24
+ if (this.eol === true) return
23
25
  const timeoutId = setTimeout(
24
26
  () => {
25
27
  this[symbols.timeouts] = this[symbols.timeouts].filter((id) => id !== timeoutId)
@@ -59,6 +61,8 @@ export default {
59
61
  },
60
62
  $setInterval: {
61
63
  value: function (fn, ms, ...params) {
64
+ // early exit when component is marked as end of life
65
+ if (this.eol === true) return
62
66
  const intervalId = setInterval(() => fn.apply(null, params), ms, params)
63
67
  this[symbols.intervals].push(intervalId)
64
68
  return intervalId