@ngrx/signals 17.1.1 → 18.0.0-beta.0
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/entities/src/models.d.ts +2 -4
- package/esm2022/entities/src/helpers.mjs +1 -1
- package/esm2022/entities/src/models.mjs +1 -1
- package/esm2022/rxjs-interop/src/rx-method.mjs +1 -1
- package/esm2022/src/deep-signal.mjs +1 -1
- package/esm2022/src/helpers.mjs +1 -1
- package/esm2022/src/patch-state.mjs +1 -1
- package/esm2022/src/signal-store.mjs +4 -4
- package/esm2022/src/with-hooks.mjs +1 -1
- package/fesm2022/ngrx-signals-entities.mjs +191 -174
- package/fesm2022/ngrx-signals-entities.mjs.map +7 -1
- package/fesm2022/ngrx-signals-rxjs-interop.mjs +33 -36
- package/fesm2022/ngrx-signals-rxjs-interop.mjs.map +7 -1
- package/fesm2022/ngrx-signals.mjs +176 -162
- package/fesm2022/ngrx-signals.mjs.map +7 -1
- package/package.json +2 -2
- package/schematics-core/utility/ast-utils.js.map +1 -1
- package/schematics-core/utility/change.js.map +1 -1
- package/schematics-core/utility/config.js.map +1 -1
- package/schematics-core/utility/find-component.js.map +1 -1
- package/schematics-core/utility/find-module.js.map +1 -1
- package/schematics-core/utility/json-utilts.js.map +1 -1
- package/schematics-core/utility/libs-version.js +1 -1
- package/schematics-core/utility/libs-version.js.map +1 -1
- package/schematics-core/utility/ngrx-utils.js.map +1 -1
- package/schematics-core/utility/package.js.map +1 -1
- package/schematics-core/utility/project.js.map +1 -1
- package/schematics-core/utility/strings.js.map +1 -1
- package/schematics-core/utility/update.js.map +1 -1
- package/schematics-core/utility/visitors.js.map +1 -1
- package/src/patch-state.d.ts +2 -1
|
@@ -1,40 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
// src/rx-method.mjs
|
|
2
|
+
import { assertInInjectionContext, DestroyRef, effect, inject, Injector, isSignal, untracked } from "@angular/core";
|
|
3
|
+
import { isObservable, noop, Subject } from "rxjs";
|
|
4
4
|
function rxMethod(generator, config) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
if (!config?.injector) {
|
|
6
|
+
assertInInjectionContext(rxMethod);
|
|
7
|
+
}
|
|
8
|
+
const injector = config?.injector ?? inject(Injector);
|
|
9
|
+
const destroyRef = injector.get(DestroyRef);
|
|
10
|
+
const source$ = new Subject();
|
|
11
|
+
const sourceSub = generator(source$).subscribe();
|
|
12
|
+
destroyRef.onDestroy(() => sourceSub.unsubscribe());
|
|
13
|
+
const rxMethodFn = (input) => {
|
|
14
|
+
if (isSignal(input)) {
|
|
15
|
+
const watcher = effect(() => {
|
|
16
|
+
const value = input();
|
|
17
|
+
untracked(() => source$.next(value));
|
|
18
|
+
}, { injector });
|
|
19
|
+
const instanceSub = { unsubscribe: () => watcher.destroy() };
|
|
20
|
+
sourceSub.add(instanceSub);
|
|
21
|
+
return instanceSub;
|
|
7
22
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, { injector });
|
|
19
|
-
const instanceSub = { unsubscribe: () => watcher.destroy() };
|
|
20
|
-
sourceSub.add(instanceSub);
|
|
21
|
-
return instanceSub;
|
|
22
|
-
}
|
|
23
|
-
if (isObservable(input)) {
|
|
24
|
-
const instanceSub = input.subscribe((value) => source$.next(value));
|
|
25
|
-
sourceSub.add(instanceSub);
|
|
26
|
-
return instanceSub;
|
|
27
|
-
}
|
|
28
|
-
source$.next(input);
|
|
29
|
-
return { unsubscribe: noop };
|
|
30
|
-
};
|
|
31
|
-
rxMethodFn.unsubscribe = sourceSub.unsubscribe.bind(sourceSub);
|
|
32
|
-
return rxMethodFn;
|
|
23
|
+
if (isObservable(input)) {
|
|
24
|
+
const instanceSub = input.subscribe((value) => source$.next(value));
|
|
25
|
+
sourceSub.add(instanceSub);
|
|
26
|
+
return instanceSub;
|
|
27
|
+
}
|
|
28
|
+
source$.next(input);
|
|
29
|
+
return { unsubscribe: noop };
|
|
30
|
+
};
|
|
31
|
+
rxMethodFn.unsubscribe = sourceSub.unsubscribe.bind(sourceSub);
|
|
32
|
+
return rxMethodFn;
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
*/
|
|
38
|
-
|
|
39
|
-
export { rxMethod };
|
|
34
|
+
export {
|
|
35
|
+
rxMethod
|
|
36
|
+
};
|
|
40
37
|
//# sourceMappingURL=ngrx-signals-rxjs-interop.mjs.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../modules/signals/rxjs-interop/src/rx-method.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n assertInInjectionContext,\n DestroyRef,\n effect,\n inject,\n Injector,\n isSignal,\n Signal,\n untracked,\n} from '@angular/core';\nimport { isObservable, noop, Observable, Subject, Unsubscribable } from 'rxjs';\n\ntype RxMethodInput<Input> = Input | Observable<Input> | Signal<Input>;\n\ntype RxMethod<Input> = ((input: RxMethodInput<Input>) => Unsubscribable) &\n Unsubscribable;\n\nexport function rxMethod<Input>(\n generator: (source$: Observable<Input>) => Observable<unknown>,\n config?: { injector?: Injector }\n): RxMethod<Input> {\n if (!config?.injector) {\n assertInInjectionContext(rxMethod);\n }\n\n const injector = config?.injector ?? inject(Injector);\n const destroyRef = injector.get(DestroyRef);\n const source$ = new Subject<Input>();\n\n const sourceSub = generator(source$).subscribe();\n destroyRef.onDestroy(() => sourceSub.unsubscribe());\n\n const rxMethodFn = (input: RxMethodInput<Input>) => {\n if (isSignal(input)) {\n const watcher = effect(\n () => {\n const value = input();\n untracked(() => source$.next(value));\n },\n { injector }\n );\n const instanceSub = { unsubscribe: () => watcher.destroy() };\n sourceSub.add(instanceSub);\n\n return instanceSub;\n }\n\n if (isObservable(input)) {\n const instanceSub = input.subscribe((value) => source$.next(value));\n sourceSub.add(instanceSub);\n\n return instanceSub;\n }\n\n source$.next(input);\n return { unsubscribe: noop };\n };\n rxMethodFn.unsubscribe = sourceSub.unsubscribe.bind(sourceSub);\n\n return rxMethodFn;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SACE,0BACA,YACA,QACA,QACA,UACA,UAEA,iBACK;AACP,SAAS,cAAc,MAAkB,eAA+B;AAOlE,SAAU,SACd,WACA,QAAgC;AAEhC,MAAI,CAAC,QAAQ,UAAU;AACrB,6BAAyB,QAAQ;EACnC;AAEA,QAAM,WAAW,QAAQ,YAAY,OAAO,QAAQ;AACpD,QAAM,aAAa,SAAS,IAAI,UAAU;AAC1C,QAAM,UAAU,IAAI,QAAO;AAE3B,QAAM,YAAY,UAAU,OAAO,EAAE,UAAS;AAC9C,aAAW,UAAU,MAAM,UAAU,YAAW,CAAE;AAElD,QAAM,aAAa,CAAC,UAA+B;AACjD,QAAI,SAAS,KAAK,GAAG;AACnB,YAAM,UAAU,OACd,MAAK;AACH,cAAM,QAAQ,MAAK;AACnB,kBAAU,MAAM,QAAQ,KAAK,KAAK,CAAC;MACrC,GACA,EAAE,SAAQ,CAAE;AAEd,YAAM,cAAc,EAAE,aAAa,MAAM,QAAQ,QAAO,EAAE;AAC1D,gBAAU,IAAI,WAAW;AAEzB,aAAO;IACT;AAEA,QAAI,aAAa,KAAK,GAAG;AACvB,YAAM,cAAc,MAAM,UAAU,CAAC,UAAU,QAAQ,KAAK,KAAK,CAAC;AAClE,gBAAU,IAAI,WAAW;AAEzB,aAAO;IACT;AAEA,YAAQ,KAAK,KAAK;AAClB,WAAO,EAAE,aAAa,KAAI;EAC5B;AACA,aAAW,cAAc,UAAU,YAAY,KAAK,SAAS;AAE7D,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,207 +1,221 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const STATE_SIGNAL = Symbol('STATE_SIGNAL');
|
|
1
|
+
// src/state-signal.mjs
|
|
2
|
+
var STATE_SIGNAL = Symbol("STATE_SIGNAL");
|
|
5
3
|
|
|
4
|
+
// src/get-state.mjs
|
|
6
5
|
function getState(stateSignal) {
|
|
7
|
-
|
|
6
|
+
return stateSignal[STATE_SIGNAL]();
|
|
8
7
|
}
|
|
9
8
|
|
|
9
|
+
// src/patch-state.mjs
|
|
10
10
|
function patchState(stateSignal, ...updaters) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
stateSignal[STATE_SIGNAL].update((currentState) => updaters.reduce((nextState, updater) => ({
|
|
12
|
+
...nextState,
|
|
13
|
+
...typeof updater === "function" ? updater(nextState) : updater
|
|
14
|
+
}), currentState));
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
// src/deep-signal.mjs
|
|
18
|
+
import { computed, isSignal, untracked } from "@angular/core";
|
|
19
|
+
function toDeepSignal(signal3) {
|
|
20
|
+
const value = untracked(() => signal3());
|
|
21
|
+
if (!isRecord(value)) {
|
|
22
|
+
return signal3;
|
|
23
|
+
}
|
|
24
|
+
return new Proxy(signal3, {
|
|
25
|
+
get(target, prop) {
|
|
26
|
+
if (!(prop in value)) {
|
|
27
|
+
return target[prop];
|
|
28
|
+
}
|
|
29
|
+
if (!isSignal(target[prop])) {
|
|
30
|
+
Object.defineProperty(target, prop, {
|
|
31
|
+
value: computed(() => target()[prop]),
|
|
32
|
+
configurable: true
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return toDeepSignal(target[prop]);
|
|
21
36
|
}
|
|
22
|
-
|
|
23
|
-
get(target, prop) {
|
|
24
|
-
if (!(prop in value)) {
|
|
25
|
-
return target[prop];
|
|
26
|
-
}
|
|
27
|
-
if (!isSignal(target[prop])) {
|
|
28
|
-
Object.defineProperty(target, prop, {
|
|
29
|
-
value: computed(() => target()[prop]),
|
|
30
|
-
configurable: true,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return toDeepSignal(target[prop]);
|
|
34
|
-
},
|
|
35
|
-
});
|
|
37
|
+
});
|
|
36
38
|
}
|
|
37
39
|
function isRecord(value) {
|
|
38
|
-
|
|
40
|
+
return value?.constructor === Object;
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
// src/signal-state.mjs
|
|
44
|
+
import { signal } from "@angular/core";
|
|
41
45
|
function signalState(initialState) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const stateSignal = signal(initialState);
|
|
47
|
+
const deepSignal = toDeepSignal(stateSignal.asReadonly());
|
|
48
|
+
Object.defineProperty(deepSignal, STATE_SIGNAL, {
|
|
49
|
+
value: stateSignal
|
|
50
|
+
});
|
|
51
|
+
return deepSignal;
|
|
48
52
|
}
|
|
49
53
|
|
|
54
|
+
// src/signal-store.mjs
|
|
55
|
+
import { DestroyRef, inject, Injectable, signal as signal2 } from "@angular/core";
|
|
56
|
+
import * as i0 from "@angular/core";
|
|
50
57
|
function signalStore(...args) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
inject(DestroyRef).onDestroy(onDestroy);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.0", ngImport: i0, type: SignalStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
74
|
-
/** @nocollapse */ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.0", ngImport: i0, type: SignalStore, providedIn: config.providedIn || null });
|
|
58
|
+
const signalStoreArgs = [...args];
|
|
59
|
+
const config = "providedIn" in signalStoreArgs[0] ? signalStoreArgs.shift() : {};
|
|
60
|
+
const features = signalStoreArgs;
|
|
61
|
+
class SignalStore {
|
|
62
|
+
constructor() {
|
|
63
|
+
const innerStore = features.reduce((store, feature) => feature(store), getInitialInnerStore());
|
|
64
|
+
const { slices, signals, methods, hooks } = innerStore;
|
|
65
|
+
const props = { ...slices, ...signals, ...methods };
|
|
66
|
+
this[STATE_SIGNAL] = innerStore[STATE_SIGNAL];
|
|
67
|
+
for (const key in props) {
|
|
68
|
+
this[key] = props[key];
|
|
69
|
+
}
|
|
70
|
+
const { onInit, onDestroy } = hooks;
|
|
71
|
+
if (onInit) {
|
|
72
|
+
onInit();
|
|
73
|
+
}
|
|
74
|
+
if (onDestroy) {
|
|
75
|
+
inject(DestroyRef).onDestroy(onDestroy);
|
|
76
|
+
}
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
/** @nocollapse */
|
|
79
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.0-next.6", ngImport: i0, type: SignalStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
80
|
+
/** @nocollapse */
|
|
81
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.0-next.6", ngImport: i0, type: SignalStore, providedIn: config.providedIn || null });
|
|
82
|
+
}
|
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.0-next.6", ngImport: i0, type: SignalStore, decorators: [{
|
|
84
|
+
type: Injectable,
|
|
85
|
+
args: [{ providedIn: config.providedIn || null }]
|
|
86
|
+
}], ctorParameters: () => [] });
|
|
87
|
+
return SignalStore;
|
|
81
88
|
}
|
|
82
89
|
function getInitialInnerStore() {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
return {
|
|
91
|
+
[STATE_SIGNAL]: signal2({}),
|
|
92
|
+
slices: {},
|
|
93
|
+
signals: {},
|
|
94
|
+
methods: {},
|
|
95
|
+
hooks: {}
|
|
96
|
+
};
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
// src/signal-store-feature.mjs
|
|
92
100
|
function signalStoreFeature(featureOrInput, ...restFeatures) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
: restFeatures;
|
|
96
|
-
return (inputStore) => features.reduce((store, feature) => feature(store), inputStore);
|
|
101
|
+
const features = typeof featureOrInput === "function" ? [featureOrInput, ...restFeatures] : restFeatures;
|
|
102
|
+
return (inputStore) => features.reduce((store, feature) => feature(store), inputStore);
|
|
97
103
|
}
|
|
98
104
|
function type() {
|
|
99
|
-
|
|
105
|
+
return void 0;
|
|
100
106
|
}
|
|
101
107
|
|
|
108
|
+
// src/helpers.mjs
|
|
102
109
|
function excludeKeys(obj, keys) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
111
|
+
if (!keys.includes(key)) {
|
|
112
|
+
acc[key] = obj[key];
|
|
113
|
+
}
|
|
114
|
+
return acc;
|
|
115
|
+
}, {});
|
|
109
116
|
}
|
|
110
117
|
|
|
118
|
+
// src/with-computed.mjs
|
|
111
119
|
function withComputed(signalsFactory) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
120
|
+
return (store) => {
|
|
121
|
+
const signals = signalsFactory({ ...store.slices, ...store.signals });
|
|
122
|
+
const signalsKeys = Object.keys(signals);
|
|
123
|
+
const slices = excludeKeys(store.slices, signalsKeys);
|
|
124
|
+
const methods = excludeKeys(store.methods, signalsKeys);
|
|
125
|
+
return {
|
|
126
|
+
...store,
|
|
127
|
+
slices,
|
|
128
|
+
signals: { ...store.signals, ...signals },
|
|
129
|
+
methods
|
|
123
130
|
};
|
|
131
|
+
};
|
|
124
132
|
}
|
|
125
133
|
|
|
134
|
+
// src/with-hooks.mjs
|
|
126
135
|
function withHooks(hooksOrFactory) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
const hooks = typeof hooksOrFactory === 'function'
|
|
135
|
-
? hooksOrFactory(storeProps)
|
|
136
|
-
: hooksOrFactory;
|
|
137
|
-
const createHook = (name) => {
|
|
138
|
-
const hook = hooks[name];
|
|
139
|
-
const currentHook = store.hooks[name];
|
|
140
|
-
return hook
|
|
141
|
-
? () => {
|
|
142
|
-
if (currentHook) {
|
|
143
|
-
currentHook();
|
|
144
|
-
}
|
|
145
|
-
hook(storeProps);
|
|
146
|
-
}
|
|
147
|
-
: currentHook;
|
|
148
|
-
};
|
|
149
|
-
return {
|
|
150
|
-
...store,
|
|
151
|
-
hooks: {
|
|
152
|
-
onInit: createHook('onInit'),
|
|
153
|
-
onDestroy: createHook('onDestroy'),
|
|
154
|
-
},
|
|
155
|
-
};
|
|
136
|
+
return (store) => {
|
|
137
|
+
const storeProps = {
|
|
138
|
+
[STATE_SIGNAL]: store[STATE_SIGNAL],
|
|
139
|
+
...store.slices,
|
|
140
|
+
...store.signals,
|
|
141
|
+
...store.methods
|
|
156
142
|
};
|
|
143
|
+
const hooks = typeof hooksOrFactory === "function" ? hooksOrFactory(storeProps) : hooksOrFactory;
|
|
144
|
+
const createHook = (name) => {
|
|
145
|
+
const hook = hooks[name];
|
|
146
|
+
const currentHook = store.hooks[name];
|
|
147
|
+
return hook ? () => {
|
|
148
|
+
if (currentHook) {
|
|
149
|
+
currentHook();
|
|
150
|
+
}
|
|
151
|
+
hook(storeProps);
|
|
152
|
+
} : currentHook;
|
|
153
|
+
};
|
|
154
|
+
return {
|
|
155
|
+
...store,
|
|
156
|
+
hooks: {
|
|
157
|
+
onInit: createHook("onInit"),
|
|
158
|
+
onDestroy: createHook("onDestroy")
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
};
|
|
157
162
|
}
|
|
158
163
|
|
|
164
|
+
// src/with-methods.mjs
|
|
159
165
|
function withMethods(methodsFactory) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
};
|
|
166
|
+
return (store) => {
|
|
167
|
+
const methods = methodsFactory({
|
|
168
|
+
[STATE_SIGNAL]: store[STATE_SIGNAL],
|
|
169
|
+
...store.slices,
|
|
170
|
+
...store.signals,
|
|
171
|
+
...store.methods
|
|
172
|
+
});
|
|
173
|
+
const methodsKeys = Object.keys(methods);
|
|
174
|
+
const slices = excludeKeys(store.slices, methodsKeys);
|
|
175
|
+
const signals = excludeKeys(store.signals, methodsKeys);
|
|
176
|
+
return {
|
|
177
|
+
...store,
|
|
178
|
+
slices,
|
|
179
|
+
signals,
|
|
180
|
+
methods: { ...store.methods, ...methods }
|
|
176
181
|
};
|
|
182
|
+
};
|
|
177
183
|
}
|
|
178
184
|
|
|
185
|
+
// src/with-state.mjs
|
|
186
|
+
import { computed as computed2 } from "@angular/core";
|
|
179
187
|
function withState(stateOrFactory) {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
};
|
|
188
|
+
return (store) => {
|
|
189
|
+
const state = typeof stateOrFactory === "function" ? stateOrFactory() : stateOrFactory;
|
|
190
|
+
const stateKeys = Object.keys(state);
|
|
191
|
+
store[STATE_SIGNAL].update((currentState) => ({
|
|
192
|
+
...currentState,
|
|
193
|
+
...state
|
|
194
|
+
}));
|
|
195
|
+
const slices = stateKeys.reduce((acc, key) => {
|
|
196
|
+
const slice = computed2(() => store[STATE_SIGNAL]()[key]);
|
|
197
|
+
return { ...acc, [key]: toDeepSignal(slice) };
|
|
198
|
+
}, {});
|
|
199
|
+
const signals = excludeKeys(store.signals, stateKeys);
|
|
200
|
+
const methods = excludeKeys(store.methods, stateKeys);
|
|
201
|
+
return {
|
|
202
|
+
...store,
|
|
203
|
+
slices: { ...store.slices, ...slices },
|
|
204
|
+
signals,
|
|
205
|
+
methods
|
|
199
206
|
};
|
|
207
|
+
};
|
|
200
208
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
209
|
+
export {
|
|
210
|
+
getState,
|
|
211
|
+
patchState,
|
|
212
|
+
signalState,
|
|
213
|
+
signalStore,
|
|
214
|
+
signalStoreFeature,
|
|
215
|
+
type,
|
|
216
|
+
withComputed,
|
|
217
|
+
withHooks,
|
|
218
|
+
withMethods,
|
|
219
|
+
withState
|
|
220
|
+
};
|
|
207
221
|
//# sourceMappingURL=ngrx-signals.mjs.map
|