@xaendar/core 0.4.6 → 0.4.9

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.
@@ -2,6 +2,7 @@ import { AccessorDecorator } from '@xaendar/types';
2
2
  import { Beautify } from '@xaendar/types';
3
3
  import { ClassDecorator as ClassDecorator_2 } from '@xaendar/types';
4
4
  import { Constructor } from '@xaendar/types';
5
+ import { NoArgsVoidFunction } from '@xaendar/types';
5
6
  import { RequireOne } from '@xaendar/types';
6
7
  import { SignalOptions } from '@xaendar/signals';
7
8
  import { SignalOptions as SignalOptions_2 } from '@xaendar/signals';
@@ -15,6 +16,10 @@ import { VoidFunction as VoidFunction_2 } from '@xaendar/types';
15
16
  * It won't appear by intellisense but it's there.
16
17
  */
17
18
  export declare class BaseWebComponent extends HTMLElement {
19
+ /**
20
+ * Array of functions to unwatch all the signals used in the component
21
+ */
22
+ protected unwatchFns: NoArgsVoidFunction[];
18
23
  /**
19
24
  * The root of the Web Component, where the content is rendered
20
25
  */
@@ -207,6 +207,10 @@ function setSelectors(klass, selectors) {
207
207
  * It won't appear by intellisense but it's there.
208
208
  */
209
209
  var BaseWebComponent = class extends HTMLElement {
210
+ /**
211
+ * Array of functions to unwatch all the signals used in the component
212
+ */
213
+ unwatchFns = new Array();
210
214
  /**
211
215
  * The root of the Web Component, where the content is rendered
212
216
  */
@@ -220,7 +224,9 @@ var BaseWebComponent = class extends HTMLElement {
220
224
  * update the rendering of the component
221
225
  * @internal
222
226
  */
223
- _render() {}
227
+ _render() {
228
+ return [];
229
+ }
224
230
  /**
225
231
  * Method automatically called by the JavascriptEngine when an attribute
226
232
  * on the host element is changed
@@ -245,7 +251,7 @@ var BaseWebComponent = class extends HTMLElement {
245
251
  * This method is called EVERY time the element is added
246
252
  */
247
253
  connectedCallback() {
248
- this._render();
254
+ this.unwatchFns = this._render();
249
255
  }
250
256
  /**
251
257
  * Method automatically called by the JavascriptEngine when a CustomElement
@@ -257,7 +263,10 @@ var BaseWebComponent = class extends HTMLElement {
257
263
  * so that if the element is re-added to the DOM
258
264
  * the properties initialization won't call the render method
259
265
  */
260
- disconnectedCallback() {}
266
+ disconnectedCallback() {
267
+ this.unwatchFns.forEach((unwatch) => unwatch());
268
+ this.unwatchFns = [];
269
+ }
261
270
  };
262
271
  //#endregion
263
272
  export { BaseWebComponent, Event, InputSignal, Property, WebComponent };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaendar/core",
3
- "version": "0.4.6",
3
+ "version": "0.4.9",
4
4
  "description": "A library containing core utils such as webcomponent base classes and theming support",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@xaendar/signals": "0.4.6",
20
- "@xaendar/types": "0.4.6"
19
+ "@xaendar/signals": "0.4.9",
20
+ "@xaendar/types": "0.4.9"
21
21
  }
22
22
  }