@oscarpalmer/mora 0.18.2 → 0.20.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/dist/helpers/proxy.cjs +13 -0
- package/dist/helpers/proxy.js +13 -0
- package/dist/mora.full.js +58 -14
- package/dist/value/array.cjs +33 -13
- package/dist/value/array.js +34 -14
- package/dist/value/signal.cjs +1 -1
- package/dist/value/signal.js +1 -1
- package/dist/value/store.cjs +28 -1
- package/dist/value/store.js +29 -2
- package/package.json +3 -3
- package/src/batch.ts +1 -1
- package/src/helpers/proxy.ts +45 -1
- package/src/index.ts +1 -0
- package/src/subscription.ts +2 -2
- package/src/value/array.ts +69 -13
- package/src/value/reactive.ts +2 -1
- package/src/value/signal.ts +1 -1
- package/src/value/store.ts +59 -3
- package/types/batch.d.cts +5 -5
- package/types/batch.d.ts +1 -1
- package/types/helpers/is.d.cts +43 -10
- package/types/helpers/proxy.d.cts +159 -5
- package/types/helpers/proxy.d.ts +6 -1
- package/types/helpers/value.d.cts +4 -4
- package/types/index.d.cts +43 -10
- package/types/subscription.d.cts +4 -4
- package/types/subscription.d.ts +3 -3
- package/types/value/array.d.cts +25 -9
- package/types/value/array.d.ts +22 -5
- package/types/value/computed.d.cts +4 -4
- package/types/value/reactive.d.cts +4 -4
- package/types/value/reactive.d.ts +2 -1
- package/types/value/signal.d.cts +5 -5
- package/types/value/signal.d.ts +1 -1
- package/types/value/store.d.cts +21 -4
- package/types/value/store.d.ts +18 -0
package/types/index.d.cts
CHANGED
|
@@ -68,13 +68,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
68
68
|
computeds: Set<Computed<unknown>>;
|
|
69
69
|
effects: Set<Effect>;
|
|
70
70
|
equal: (first: Equal, second: Equal) => boolean;
|
|
71
|
-
subscriptions: Map<
|
|
71
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
72
72
|
value: Value;
|
|
73
73
|
};
|
|
74
|
-
declare class Subscription
|
|
75
|
-
state: ReactiveState<
|
|
74
|
+
declare class Subscription {
|
|
75
|
+
state: ReactiveState<unknown, never>;
|
|
76
76
|
callback: GenericCallback;
|
|
77
|
-
constructor(state: ReactiveState<
|
|
77
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Unsubscribe from changes
|
|
@@ -99,10 +99,6 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
99
99
|
*/
|
|
100
100
|
set length(value: number);
|
|
101
101
|
constructor(value: Item[], options?: ReactiveOptions<Item>);
|
|
102
|
-
/**
|
|
103
|
-
* Get an indexed item
|
|
104
|
-
*/
|
|
105
|
-
at(index: number): Item | undefined;
|
|
106
102
|
/**
|
|
107
103
|
* Clear the array
|
|
108
104
|
*/
|
|
@@ -111,6 +107,14 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
111
107
|
* @inheritdoc
|
|
112
108
|
*/
|
|
113
109
|
get(): Item[];
|
|
110
|
+
/**
|
|
111
|
+
* Get the value at an index
|
|
112
|
+
*/
|
|
113
|
+
get(index: number): Item | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Get the length of the array
|
|
116
|
+
*/
|
|
117
|
+
get(property: "length"): number;
|
|
114
118
|
/**
|
|
115
119
|
* Create a computed, filtered array
|
|
116
120
|
*/
|
|
@@ -138,7 +142,7 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
138
142
|
/**
|
|
139
143
|
* Set the value
|
|
140
144
|
*/
|
|
141
|
-
set(value
|
|
145
|
+
set(value?: Item[]): void;
|
|
142
146
|
/**
|
|
143
147
|
* Set the value at an index
|
|
144
148
|
*/
|
|
@@ -155,10 +159,22 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
155
159
|
* Remove and return items from the array _(and optionally add new items)_
|
|
156
160
|
*/
|
|
157
161
|
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
162
|
+
/**
|
|
163
|
+
* @inheritdoc
|
|
164
|
+
*/
|
|
165
|
+
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
166
|
+
/**
|
|
167
|
+
* Subscribe to changes at a specific index
|
|
168
|
+
*/
|
|
169
|
+
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
158
170
|
/**
|
|
159
171
|
* Add items to the beginning of the array
|
|
160
172
|
*/
|
|
161
173
|
unshift(...items: Item[]): number;
|
|
174
|
+
/**
|
|
175
|
+
* Update the value _(based on the current value)_
|
|
176
|
+
*/
|
|
177
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
162
178
|
}
|
|
163
179
|
/**
|
|
164
180
|
* Create a reactive array
|
|
@@ -175,7 +191,7 @@ export declare class Signal<Value> extends Reactive<Value> {
|
|
|
175
191
|
*/
|
|
176
192
|
set(value: Value): void;
|
|
177
193
|
/**
|
|
178
|
-
* Update the value
|
|
194
|
+
* Update the value _(based on the current value)_
|
|
179
195
|
*/
|
|
180
196
|
update(callback: (value: Value) => Value): void;
|
|
181
197
|
}
|
|
@@ -184,6 +200,7 @@ export declare class Signal<Value> extends Reactive<Value> {
|
|
|
184
200
|
*/
|
|
185
201
|
export declare function signal<Value>(value: Value, options?: ReactiveOptions<Value>): Signal<Value>;
|
|
186
202
|
export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
203
|
+
#private;
|
|
187
204
|
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
188
205
|
/**
|
|
189
206
|
* @inheritdoc
|
|
@@ -221,6 +238,22 @@ export declare class Store<Value extends PlainObject> extends Reactive<Value, Va
|
|
|
221
238
|
* Set a value by key
|
|
222
239
|
*/
|
|
223
240
|
set(key: Key, value: unknown): void;
|
|
241
|
+
/**
|
|
242
|
+
* @inheritdoc
|
|
243
|
+
*/
|
|
244
|
+
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
245
|
+
/**
|
|
246
|
+
* Subscribe to changes for a specific key
|
|
247
|
+
*/
|
|
248
|
+
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
249
|
+
/**
|
|
250
|
+
* Subscribe to changes for a specific key
|
|
251
|
+
*/
|
|
252
|
+
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
253
|
+
/**
|
|
254
|
+
* Update the value _(based on the current value)_
|
|
255
|
+
*/
|
|
256
|
+
update(callback: (value: Value) => Value): void;
|
|
224
257
|
}
|
|
225
258
|
/**
|
|
226
259
|
* Create a reactive store
|
package/types/subscription.d.cts
CHANGED
|
@@ -52,13 +52,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
52
52
|
computeds: Set<Computed<unknown>>;
|
|
53
53
|
effects: Set<Effect>;
|
|
54
54
|
equal: (first: Equal, second: Equal) => boolean;
|
|
55
|
-
subscriptions: Map<
|
|
55
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
56
56
|
value: Value;
|
|
57
57
|
};
|
|
58
|
-
export declare class Subscription
|
|
59
|
-
state: ReactiveState<
|
|
58
|
+
export declare class Subscription {
|
|
59
|
+
state: ReactiveState<unknown, never>;
|
|
60
60
|
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<
|
|
61
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Unsubscribe from changes
|
package/types/subscription.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { GenericCallback } from '@oscarpalmer/atoms/models';
|
|
2
2
|
import type { ReactiveState } from './value/reactive';
|
|
3
|
-
export declare class Subscription
|
|
4
|
-
state: ReactiveState<
|
|
3
|
+
export declare class Subscription {
|
|
4
|
+
state: ReactiveState<unknown, never>;
|
|
5
5
|
callback: GenericCallback;
|
|
6
|
-
constructor(state: ReactiveState<
|
|
6
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* Unsubscribe from changes
|
package/types/value/array.d.cts
CHANGED
|
@@ -52,13 +52,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
52
52
|
computeds: Set<Computed<unknown>>;
|
|
53
53
|
effects: Set<Effect>;
|
|
54
54
|
equal: (first: Equal, second: Equal) => boolean;
|
|
55
|
-
subscriptions: Map<
|
|
55
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
56
56
|
value: Value;
|
|
57
57
|
};
|
|
58
|
-
declare class Subscription
|
|
59
|
-
state: ReactiveState<
|
|
58
|
+
declare class Subscription {
|
|
59
|
+
state: ReactiveState<unknown, never>;
|
|
60
60
|
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<
|
|
61
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Unsubscribe from changes
|
|
@@ -75,10 +75,6 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
75
75
|
*/
|
|
76
76
|
set length(value: number);
|
|
77
77
|
constructor(value: Item[], options?: ReactiveOptions<Item>);
|
|
78
|
-
/**
|
|
79
|
-
* Get an indexed item
|
|
80
|
-
*/
|
|
81
|
-
at(index: number): Item | undefined;
|
|
82
78
|
/**
|
|
83
79
|
* Clear the array
|
|
84
80
|
*/
|
|
@@ -87,6 +83,14 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
87
83
|
* @inheritdoc
|
|
88
84
|
*/
|
|
89
85
|
get(): Item[];
|
|
86
|
+
/**
|
|
87
|
+
* Get the value at an index
|
|
88
|
+
*/
|
|
89
|
+
get(index: number): Item | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Get the length of the array
|
|
92
|
+
*/
|
|
93
|
+
get(property: "length"): number;
|
|
90
94
|
/**
|
|
91
95
|
* Create a computed, filtered array
|
|
92
96
|
*/
|
|
@@ -114,7 +118,7 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
114
118
|
/**
|
|
115
119
|
* Set the value
|
|
116
120
|
*/
|
|
117
|
-
set(value
|
|
121
|
+
set(value?: Item[]): void;
|
|
118
122
|
/**
|
|
119
123
|
* Set the value at an index
|
|
120
124
|
*/
|
|
@@ -131,10 +135,22 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
131
135
|
* Remove and return items from the array _(and optionally add new items)_
|
|
132
136
|
*/
|
|
133
137
|
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
138
|
+
/**
|
|
139
|
+
* @inheritdoc
|
|
140
|
+
*/
|
|
141
|
+
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
142
|
+
/**
|
|
143
|
+
* Subscribe to changes at a specific index
|
|
144
|
+
*/
|
|
145
|
+
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
134
146
|
/**
|
|
135
147
|
* Add items to the beginning of the array
|
|
136
148
|
*/
|
|
137
149
|
unshift(...items: Item[]): number;
|
|
150
|
+
/**
|
|
151
|
+
* Update the value _(based on the current value)_
|
|
152
|
+
*/
|
|
153
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
138
154
|
}
|
|
139
155
|
/**
|
|
140
156
|
* Create a reactive array
|
package/types/value/array.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Unsubscribe } from '../subscription';
|
|
1
2
|
import { type Computed } from './computed';
|
|
2
3
|
import { Reactive, type ReactiveOptions } from './reactive';
|
|
3
4
|
export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
@@ -11,10 +12,6 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
11
12
|
*/
|
|
12
13
|
set length(value: number);
|
|
13
14
|
constructor(value: Item[], options?: ReactiveOptions<Item>);
|
|
14
|
-
/**
|
|
15
|
-
* Get an indexed item
|
|
16
|
-
*/
|
|
17
|
-
at(index: number): Item | undefined;
|
|
18
15
|
/**
|
|
19
16
|
* Clear the array
|
|
20
17
|
*/
|
|
@@ -23,6 +20,14 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
23
20
|
* @inheritdoc
|
|
24
21
|
*/
|
|
25
22
|
get(): Item[];
|
|
23
|
+
/**
|
|
24
|
+
* Get the value at an index
|
|
25
|
+
*/
|
|
26
|
+
get(index: number): Item | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get the length of the array
|
|
29
|
+
*/
|
|
30
|
+
get(property: 'length'): number;
|
|
26
31
|
/**
|
|
27
32
|
* Create a computed, filtered array
|
|
28
33
|
*/
|
|
@@ -50,7 +55,7 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
50
55
|
/**
|
|
51
56
|
* Set the value
|
|
52
57
|
*/
|
|
53
|
-
set(value
|
|
58
|
+
set(value?: Item[]): void;
|
|
54
59
|
/**
|
|
55
60
|
* Set the value at an index
|
|
56
61
|
*/
|
|
@@ -67,10 +72,22 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
67
72
|
* Remove and return items from the array _(and optionally add new items)_
|
|
68
73
|
*/
|
|
69
74
|
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
75
|
+
/**
|
|
76
|
+
* @inheritdoc
|
|
77
|
+
*/
|
|
78
|
+
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
79
|
+
/**
|
|
80
|
+
* Subscribe to changes at a specific index
|
|
81
|
+
*/
|
|
82
|
+
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
70
83
|
/**
|
|
71
84
|
* Add items to the beginning of the array
|
|
72
85
|
*/
|
|
73
86
|
unshift(...items: Item[]): number;
|
|
87
|
+
/**
|
|
88
|
+
* Update the value _(based on the current value)_
|
|
89
|
+
*/
|
|
90
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
74
91
|
}
|
|
75
92
|
/**
|
|
76
93
|
* Create a reactive array
|
|
@@ -65,13 +65,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
65
65
|
computeds: Set<Computed<unknown>>;
|
|
66
66
|
effects: Set<Effect>;
|
|
67
67
|
equal: (first: Equal, second: Equal) => boolean;
|
|
68
|
-
subscriptions: Map<
|
|
68
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
69
69
|
value: Value;
|
|
70
70
|
};
|
|
71
|
-
declare class Subscription
|
|
72
|
-
state: ReactiveState<
|
|
71
|
+
declare class Subscription {
|
|
72
|
+
state: ReactiveState<unknown, never>;
|
|
73
73
|
callback: GenericCallback;
|
|
74
|
-
constructor(state: ReactiveState<
|
|
74
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Unsubscribe from changes
|
|
@@ -52,13 +52,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
52
52
|
computeds: Set<Computed<unknown>>;
|
|
53
53
|
effects: Set<Effect>;
|
|
54
54
|
equal: (first: Equal, second: Equal) => boolean;
|
|
55
|
-
subscriptions: Map<
|
|
55
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
56
56
|
value: Value;
|
|
57
57
|
};
|
|
58
|
-
declare class Subscription
|
|
59
|
-
state: ReactiveState<
|
|
58
|
+
declare class Subscription {
|
|
59
|
+
state: ReactiveState<unknown, never>;
|
|
60
60
|
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<
|
|
61
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Unsubscribe from changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { GenericCallback } from '@oscarpalmer/atoms/models';
|
|
1
2
|
import type { Effect } from '../effect';
|
|
2
3
|
import { type Subscription, type Unsubscribe } from '../subscription';
|
|
3
4
|
import type { Computed } from './computed';
|
|
@@ -39,6 +40,6 @@ export type ReactiveState<Value, Equal> = {
|
|
|
39
40
|
computeds: Set<Computed<unknown>>;
|
|
40
41
|
effects: Set<Effect>;
|
|
41
42
|
equal: (first: Equal, second: Equal) => boolean;
|
|
42
|
-
subscriptions: Map<
|
|
43
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
43
44
|
value: Value;
|
|
44
45
|
};
|
package/types/value/signal.d.cts
CHANGED
|
@@ -52,13 +52,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
52
52
|
computeds: Set<Computed<unknown>>;
|
|
53
53
|
effects: Set<Effect>;
|
|
54
54
|
equal: (first: Equal, second: Equal) => boolean;
|
|
55
|
-
subscriptions: Map<
|
|
55
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
56
56
|
value: Value;
|
|
57
57
|
};
|
|
58
|
-
declare class Subscription
|
|
59
|
-
state: ReactiveState<
|
|
58
|
+
declare class Subscription {
|
|
59
|
+
state: ReactiveState<unknown, never>;
|
|
60
60
|
callback: GenericCallback;
|
|
61
|
-
constructor(state: ReactiveState<
|
|
61
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Unsubscribe from changes
|
|
@@ -75,7 +75,7 @@ export declare class Signal<Value> extends Reactive<Value> {
|
|
|
75
75
|
*/
|
|
76
76
|
set(value: Value): void;
|
|
77
77
|
/**
|
|
78
|
-
* Update the value
|
|
78
|
+
* Update the value _(based on the current value)_
|
|
79
79
|
*/
|
|
80
80
|
update(callback: (value: Value) => Value): void;
|
|
81
81
|
}
|
package/types/value/signal.d.ts
CHANGED
package/types/value/store.d.cts
CHANGED
|
@@ -60,19 +60,20 @@ export type ReactiveState<Value, Equal> = {
|
|
|
60
60
|
computeds: Set<Computed<unknown>>;
|
|
61
61
|
effects: Set<Effect>;
|
|
62
62
|
equal: (first: Equal, second: Equal) => boolean;
|
|
63
|
-
subscriptions: Map<
|
|
63
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
64
64
|
value: Value;
|
|
65
65
|
};
|
|
66
|
-
declare class Subscription
|
|
67
|
-
state: ReactiveState<
|
|
66
|
+
declare class Subscription {
|
|
67
|
+
state: ReactiveState<unknown, never>;
|
|
68
68
|
callback: GenericCallback;
|
|
69
|
-
constructor(state: ReactiveState<
|
|
69
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* Unsubscribe from changes
|
|
73
73
|
*/
|
|
74
74
|
export type Unsubscribe = () => void;
|
|
75
75
|
export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
76
|
+
#private;
|
|
76
77
|
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
77
78
|
/**
|
|
78
79
|
* @inheritdoc
|
|
@@ -110,6 +111,22 @@ export declare class Store<Value extends PlainObject> extends Reactive<Value, Va
|
|
|
110
111
|
* Set a value by key
|
|
111
112
|
*/
|
|
112
113
|
set(key: Key, value: unknown): void;
|
|
114
|
+
/**
|
|
115
|
+
* @inheritdoc
|
|
116
|
+
*/
|
|
117
|
+
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
118
|
+
/**
|
|
119
|
+
* Subscribe to changes for a specific key
|
|
120
|
+
*/
|
|
121
|
+
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
122
|
+
/**
|
|
123
|
+
* Subscribe to changes for a specific key
|
|
124
|
+
*/
|
|
125
|
+
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
126
|
+
/**
|
|
127
|
+
* Update the value _(based on the current value)_
|
|
128
|
+
*/
|
|
129
|
+
update(callback: (value: Value) => Value): void;
|
|
113
130
|
}
|
|
114
131
|
/**
|
|
115
132
|
* Create a reactive store
|
package/types/value/store.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Key, PlainObject } from '@oscarpalmer/atoms/models';
|
|
2
|
+
import { type Unsubscribe } from '../subscription';
|
|
2
3
|
import { Reactive, type ReactiveOptions } from './reactive';
|
|
3
4
|
export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
5
|
+
#private;
|
|
4
6
|
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
5
7
|
/**
|
|
6
8
|
* @inheritdoc
|
|
@@ -38,6 +40,22 @@ export declare class Store<Value extends PlainObject> extends Reactive<Value, Va
|
|
|
38
40
|
* Set a value by key
|
|
39
41
|
*/
|
|
40
42
|
set(key: Key, value: unknown): void;
|
|
43
|
+
/**
|
|
44
|
+
* @inheritdoc
|
|
45
|
+
*/
|
|
46
|
+
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
47
|
+
/**
|
|
48
|
+
* Subscribe to changes for a specific key
|
|
49
|
+
*/
|
|
50
|
+
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
51
|
+
/**
|
|
52
|
+
* Subscribe to changes for a specific key
|
|
53
|
+
*/
|
|
54
|
+
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
55
|
+
/**
|
|
56
|
+
* Update the value _(based on the current value)_
|
|
57
|
+
*/
|
|
58
|
+
update(callback: (value: Value) => Value): void;
|
|
41
59
|
}
|
|
42
60
|
/**
|
|
43
61
|
* Create a reactive store
|