@slimlib/store 1.4.0 → 1.4.1

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/dist/angular.cjs CHANGED
@@ -7,17 +7,11 @@ const createStore = core.createStoreFactory(false);
7
7
  const toSignal = (store, injector) => {
8
8
  const cleanupRef = (injector ? injector.get : core$1.inject)(core$1.DestroyRef);
9
9
  const state = core$1.signal(store());
10
- const stateRef = new WeakRef(state);
11
- const unsubscribe = store((value) => {
12
- const stateSignal = stateRef.deref();
13
- if (stateSignal) {
14
- stateSignal.set(value);
15
- }
16
- else {
17
- unsubscribe();
18
- }
10
+ core$1.untracked(() => {
11
+ cleanupRef?.onDestroy(store((value) => {
12
+ state.set(value);
13
+ }));
19
14
  });
20
- cleanupRef?.onDestroy(unsubscribe);
21
15
  return state.asReadonly();
22
16
  };
23
17
  class SlimlibStore {
package/dist/angular.mjs CHANGED
@@ -1,21 +1,15 @@
1
- import { inject, DestroyRef, signal } from '@angular/core';
1
+ import { inject, DestroyRef, signal, untracked } from '@angular/core';
2
2
  import { createStoreFactory } from './core.mjs';
3
3
 
4
4
  const createStore = createStoreFactory(false);
5
5
  const toSignal = (store, injector) => {
6
6
  const cleanupRef = (injector ? injector.get : inject)(DestroyRef);
7
7
  const state = signal(store());
8
- const stateRef = new WeakRef(state);
9
- const unsubscribe = store((value) => {
10
- const stateSignal = stateRef.deref();
11
- if (stateSignal) {
12
- stateSignal.set(value);
13
- }
14
- else {
15
- unsubscribe();
16
- }
8
+ untracked(() => {
9
+ cleanupRef?.onDestroy(store((value) => {
10
+ state.set(value);
11
+ }));
17
12
  });
18
- cleanupRef?.onDestroy(unsubscribe);
19
13
  return state.asReadonly();
20
14
  };
21
15
  class SlimlibStore {
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("./core")):"function"==typeof define&&define.amd?define(["exports","@angular/core","./core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).slimlibStoreAngular={},e.angularCore,e.slimlibStoreCore)}(this,(function(e,t,o){"use strict";const n=o.createStoreFactory(!1),s=(e,o)=>{const n=(o?o.get:t.inject)(t.DestroyRef),s=t.signal(e()),i=new WeakRef(s),r=e((e=>{const t=i.deref();t?t.set(e):r()}));return n?.onDestroy(r),s.asReadonly()};e.SlimlibStore=class{store;state;signal;constructor(e){[this.state,this.store]=n(e),this.signal=s(this.store)}},e.createStore=n,e.toSignal=s}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("./core")):"function"==typeof define&&define.amd?define(["exports","@angular/core","./core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).slimlibStoreAngular={},e.angularCore,e.slimlibStoreCore)}(this,(function(e,t,o){"use strict";const s=o.createStoreFactory(!1),n=(e,o)=>{const s=(o?o.get:t.inject)(t.DestroyRef),n=t.signal(e());return t.untracked((()=>{s?.onDestroy(e((e=>{n.set(e)})))})),n.asReadonly()};e.SlimlibStore=class{store;state;signal;constructor(e){[this.state,this.store]=s(e),this.signal=n(this.store)}},e.createStore=s,e.toSignal=n}));
2
2
  //# sourceMappingURL=angular.umd.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "name": "@slimlib/store",
5
5
  "description": "Simple Proxy-based store for SPA",
6
6
  "license": "MIT",