@oscarpalmer/mora 0.19.0 → 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 +1 -1
- package/dist/helpers/proxy.js +1 -1
- package/dist/mora.full.js +36 -6
- package/dist/value/array.cjs +24 -3
- package/dist/value/array.js +24 -3
- package/dist/value/signal.cjs +1 -1
- package/dist/value/signal.js +1 -1
- package/dist/value/store.cjs +19 -1
- package/dist/value/store.js +19 -1
- package/package.json +3 -3
- package/src/batch.ts +1 -1
- package/src/helpers/proxy.ts +29 -29
- package/src/subscription.ts +2 -2
- package/src/value/array.ts +53 -5
- package/src/value/reactive.ts +2 -1
- package/src/value/signal.ts +1 -1
- package/src/value/store.ts +49 -2
- package/types/batch.d.cts +5 -5
- package/types/batch.d.ts +1 -1
- package/types/helpers/is.d.cts +40 -6
- package/types/helpers/proxy.d.cts +42 -8
- package/types/helpers/proxy.d.ts +2 -2
- package/types/helpers/value.d.cts +4 -4
- package/types/index.d.cts +40 -6
- package/types/subscription.d.cts +4 -4
- package/types/subscription.d.ts +3 -3
- package/types/value/array.d.cts +23 -5
- package/types/value/array.d.ts +20 -1
- 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 +20 -4
- package/types/value/store.d.ts +17 -0
package/types/batch.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
|
|
@@ -73,7 +73,7 @@ export declare function startBatch(): void;
|
|
|
73
73
|
* Stop batching effects and flush _(run)_ them
|
|
74
74
|
*/
|
|
75
75
|
export declare function stopBatch(): void;
|
|
76
|
-
export declare const batchedHandlers: Set<Effect | Subscription
|
|
76
|
+
export declare const batchedHandlers: Set<Effect | Subscription>;
|
|
77
77
|
export declare let batchDepth: number;
|
|
78
78
|
|
|
79
79
|
export {};
|
package/types/batch.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare function startBatch(): void;
|
|
|
9
9
|
* Stop batching effects and flush _(run)_ them
|
|
10
10
|
*/
|
|
11
11
|
export declare function stopBatch(): void;
|
|
12
|
-
export declare const batchedHandlers: Set<
|
|
12
|
+
export declare const batchedHandlers: Set<Subscription | Effect>;
|
|
13
13
|
export declare let batchDepth: number;
|
package/types/helpers/is.d.cts
CHANGED
|
@@ -60,13 +60,13 @@ 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
|
|
@@ -91,7 +91,13 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
91
91
|
* @inheritdoc
|
|
92
92
|
*/
|
|
93
93
|
get(): Item[];
|
|
94
|
+
/**
|
|
95
|
+
* Get the value at an index
|
|
96
|
+
*/
|
|
94
97
|
get(index: number): Item | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Get the length of the array
|
|
100
|
+
*/
|
|
95
101
|
get(property: "length"): number;
|
|
96
102
|
/**
|
|
97
103
|
* Create a computed, filtered array
|
|
@@ -120,7 +126,7 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
120
126
|
/**
|
|
121
127
|
* Set the value
|
|
122
128
|
*/
|
|
123
|
-
set(value
|
|
129
|
+
set(value?: Item[]): void;
|
|
124
130
|
/**
|
|
125
131
|
* Set the value at an index
|
|
126
132
|
*/
|
|
@@ -137,10 +143,22 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
137
143
|
* Remove and return items from the array _(and optionally add new items)_
|
|
138
144
|
*/
|
|
139
145
|
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
146
|
+
/**
|
|
147
|
+
* @inheritdoc
|
|
148
|
+
*/
|
|
149
|
+
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
150
|
+
/**
|
|
151
|
+
* Subscribe to changes at a specific index
|
|
152
|
+
*/
|
|
153
|
+
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
140
154
|
/**
|
|
141
155
|
* Add items to the beginning of the array
|
|
142
156
|
*/
|
|
143
157
|
unshift(...items: Item[]): number;
|
|
158
|
+
/**
|
|
159
|
+
* Update the value _(based on the current value)_
|
|
160
|
+
*/
|
|
161
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
144
162
|
}
|
|
145
163
|
declare class Signal<Value> extends Reactive<Value> {
|
|
146
164
|
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
@@ -153,7 +171,7 @@ declare class Signal<Value> extends Reactive<Value> {
|
|
|
153
171
|
*/
|
|
154
172
|
set(value: Value): void;
|
|
155
173
|
/**
|
|
156
|
-
* Update the value
|
|
174
|
+
* Update the value _(based on the current value)_
|
|
157
175
|
*/
|
|
158
176
|
update(callback: (value: Value) => Value): void;
|
|
159
177
|
}
|
|
@@ -196,6 +214,22 @@ declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
|
196
214
|
* Set a value by key
|
|
197
215
|
*/
|
|
198
216
|
set(key: Key, value: unknown): void;
|
|
217
|
+
/**
|
|
218
|
+
* @inheritdoc
|
|
219
|
+
*/
|
|
220
|
+
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
221
|
+
/**
|
|
222
|
+
* Subscribe to changes for a specific key
|
|
223
|
+
*/
|
|
224
|
+
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
225
|
+
/**
|
|
226
|
+
* Subscribe to changes for a specific key
|
|
227
|
+
*/
|
|
228
|
+
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
229
|
+
/**
|
|
230
|
+
* Update the value _(based on the current value)_
|
|
231
|
+
*/
|
|
232
|
+
update(callback: (value: Value) => Value): void;
|
|
199
233
|
}
|
|
200
234
|
/**
|
|
201
235
|
* Is the value a reactive array?
|
|
@@ -64,13 +64,13 @@ export type ReactiveState<Value, Equal> = {
|
|
|
64
64
|
computeds: Set<Computed<unknown>>;
|
|
65
65
|
effects: Set<Effect>;
|
|
66
66
|
equal: (first: Equal, second: Equal) => boolean;
|
|
67
|
-
subscriptions: Map<
|
|
67
|
+
subscriptions: Map<GenericCallback, Subscription>;
|
|
68
68
|
value: Value;
|
|
69
69
|
};
|
|
70
|
-
declare class Subscription
|
|
71
|
-
state: ReactiveState<
|
|
70
|
+
declare class Subscription {
|
|
71
|
+
state: ReactiveState<unknown, never>;
|
|
72
72
|
callback: GenericCallback;
|
|
73
|
-
constructor(state: ReactiveState<
|
|
73
|
+
constructor(state: ReactiveState<unknown, never>, callback: GenericCallback);
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Unsubscribe from changes
|
|
@@ -95,7 +95,13 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
95
95
|
* @inheritdoc
|
|
96
96
|
*/
|
|
97
97
|
get(): Item[];
|
|
98
|
+
/**
|
|
99
|
+
* Get the value at an index
|
|
100
|
+
*/
|
|
98
101
|
get(index: number): Item | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Get the length of the array
|
|
104
|
+
*/
|
|
99
105
|
get(property: "length"): number;
|
|
100
106
|
/**
|
|
101
107
|
* Create a computed, filtered array
|
|
@@ -124,7 +130,7 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
124
130
|
/**
|
|
125
131
|
* Set the value
|
|
126
132
|
*/
|
|
127
|
-
set(value
|
|
133
|
+
set(value?: Item[]): void;
|
|
128
134
|
/**
|
|
129
135
|
* Set the value at an index
|
|
130
136
|
*/
|
|
@@ -141,10 +147,22 @@ declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
141
147
|
* Remove and return items from the array _(and optionally add new items)_
|
|
142
148
|
*/
|
|
143
149
|
splice(from: number, to?: number, ...items: Item[]): Item[];
|
|
150
|
+
/**
|
|
151
|
+
* @inheritdoc
|
|
152
|
+
*/
|
|
153
|
+
subscribe(callback: (value: Item[]) => void): Unsubscribe;
|
|
154
|
+
/**
|
|
155
|
+
* Subscribe to changes at a specific index
|
|
156
|
+
*/
|
|
157
|
+
subscribe(index: number, callback: (value: Item | undefined) => void): Unsubscribe;
|
|
144
158
|
/**
|
|
145
159
|
* Add items to the beginning of the array
|
|
146
160
|
*/
|
|
147
161
|
unshift(...items: Item[]): number;
|
|
162
|
+
/**
|
|
163
|
+
* Update the value _(based on the current value)_
|
|
164
|
+
*/
|
|
165
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
148
166
|
}
|
|
149
167
|
declare class Signal<Value> extends Reactive<Value> {
|
|
150
168
|
constructor(value: Value, options?: ReactiveOptions<Value>);
|
|
@@ -157,7 +175,7 @@ declare class Signal<Value> extends Reactive<Value> {
|
|
|
157
175
|
*/
|
|
158
176
|
set(value: Value): void;
|
|
159
177
|
/**
|
|
160
|
-
* Update the value
|
|
178
|
+
* Update the value _(based on the current value)_
|
|
161
179
|
*/
|
|
162
180
|
update(callback: (value: Value) => Value): void;
|
|
163
181
|
}
|
|
@@ -200,9 +218,25 @@ declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
|
|
|
200
218
|
* Set a value by key
|
|
201
219
|
*/
|
|
202
220
|
set(key: Key, value: unknown): void;
|
|
221
|
+
/**
|
|
222
|
+
* @inheritdoc
|
|
223
|
+
*/
|
|
224
|
+
subscribe(callback: (value: Value) => void): Unsubscribe;
|
|
225
|
+
/**
|
|
226
|
+
* Subscribe to changes for a specific key
|
|
227
|
+
*/
|
|
228
|
+
subscribe<Key extends keyof Value>(key: Key, callback: (value: Value[Key] | undefined) => void): Unsubscribe;
|
|
229
|
+
/**
|
|
230
|
+
* Subscribe to changes for a specific key
|
|
231
|
+
*/
|
|
232
|
+
subscribe(key: Key, callback: (value: unknown) => void): Unsubscribe;
|
|
233
|
+
/**
|
|
234
|
+
* Update the value _(based on the current value)_
|
|
235
|
+
*/
|
|
236
|
+
update(callback: (value: Value) => Value): void;
|
|
203
237
|
}
|
|
204
|
-
export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): unknown
|
|
205
|
-
export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): unknown
|
|
238
|
+
export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): Computed<unknown>;
|
|
239
|
+
export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): Computed<unknown>;
|
|
206
240
|
export declare function setProxyValue(proxy: ArrayOrPlainObject, value: ArrayOrPlainObject): void;
|
|
207
241
|
export declare function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(target: Value, property: PropertyKey, value: unknown, state: ReactiveState<Value, Equal>, isArray: boolean, length?: Signal<number>): boolean;
|
|
208
242
|
|
package/types/helpers/proxy.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type Computed } from '../value/computed';
|
|
|
4
4
|
import type { ReactiveState } from '../value/reactive';
|
|
5
5
|
import type { Signal } from '../value/signal';
|
|
6
6
|
import type { Store } from '../value/store';
|
|
7
|
-
export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): unknown
|
|
8
|
-
export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): unknown
|
|
7
|
+
export declare function getReactiveValueInProxy<Value>(array: ReactiveArray<Value>, mapped: Map<Key, Computed<unknown>>, index: number, isArray: true): Computed<unknown>;
|
|
8
|
+
export declare function getReactiveValueInProxy<Value extends PlainObject>(store: Store<Value>, mapped: Map<Key, Computed<unknown>>, key: Key, isArray: false): Computed<unknown>;
|
|
9
9
|
export declare function setProxyValue(proxy: ArrayOrPlainObject, value: ArrayOrPlainObject): void;
|
|
10
10
|
export declare function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(target: Value, property: PropertyKey, value: unknown, state: ReactiveState<Value, Equal>, isArray: boolean, length?: Signal<number>): boolean;
|
|
@@ -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
|
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
|
|
@@ -107,7 +107,13 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
107
107
|
* @inheritdoc
|
|
108
108
|
*/
|
|
109
109
|
get(): Item[];
|
|
110
|
+
/**
|
|
111
|
+
* Get the value at an index
|
|
112
|
+
*/
|
|
110
113
|
get(index: number): Item | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Get the length of the array
|
|
116
|
+
*/
|
|
111
117
|
get(property: "length"): number;
|
|
112
118
|
/**
|
|
113
119
|
* Create a computed, filtered array
|
|
@@ -136,7 +142,7 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
136
142
|
/**
|
|
137
143
|
* Set the value
|
|
138
144
|
*/
|
|
139
|
-
set(value
|
|
145
|
+
set(value?: Item[]): void;
|
|
140
146
|
/**
|
|
141
147
|
* Set the value at an index
|
|
142
148
|
*/
|
|
@@ -153,10 +159,22 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
153
159
|
* Remove and return items from the array _(and optionally add new items)_
|
|
154
160
|
*/
|
|
155
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;
|
|
156
170
|
/**
|
|
157
171
|
* Add items to the beginning of the array
|
|
158
172
|
*/
|
|
159
173
|
unshift(...items: Item[]): number;
|
|
174
|
+
/**
|
|
175
|
+
* Update the value _(based on the current value)_
|
|
176
|
+
*/
|
|
177
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
160
178
|
}
|
|
161
179
|
/**
|
|
162
180
|
* Create a reactive array
|
|
@@ -173,7 +191,7 @@ export declare class Signal<Value> extends Reactive<Value> {
|
|
|
173
191
|
*/
|
|
174
192
|
set(value: Value): void;
|
|
175
193
|
/**
|
|
176
|
-
* Update the value
|
|
194
|
+
* Update the value _(based on the current value)_
|
|
177
195
|
*/
|
|
178
196
|
update(callback: (value: Value) => Value): void;
|
|
179
197
|
}
|
|
@@ -220,6 +238,22 @@ export declare class Store<Value extends PlainObject> extends Reactive<Value, Va
|
|
|
220
238
|
* Set a value by key
|
|
221
239
|
*/
|
|
222
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;
|
|
223
257
|
}
|
|
224
258
|
/**
|
|
225
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
|
|
@@ -83,7 +83,13 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
83
83
|
* @inheritdoc
|
|
84
84
|
*/
|
|
85
85
|
get(): Item[];
|
|
86
|
+
/**
|
|
87
|
+
* Get the value at an index
|
|
88
|
+
*/
|
|
86
89
|
get(index: number): Item | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Get the length of the array
|
|
92
|
+
*/
|
|
87
93
|
get(property: "length"): number;
|
|
88
94
|
/**
|
|
89
95
|
* Create a computed, filtered array
|
|
@@ -112,7 +118,7 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
112
118
|
/**
|
|
113
119
|
* Set the value
|
|
114
120
|
*/
|
|
115
|
-
set(value
|
|
121
|
+
set(value?: Item[]): void;
|
|
116
122
|
/**
|
|
117
123
|
* Set the value at an index
|
|
118
124
|
*/
|
|
@@ -129,10 +135,22 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
129
135
|
* Remove and return items from the array _(and optionally add new items)_
|
|
130
136
|
*/
|
|
131
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;
|
|
132
146
|
/**
|
|
133
147
|
* Add items to the beginning of the array
|
|
134
148
|
*/
|
|
135
149
|
unshift(...items: Item[]): number;
|
|
150
|
+
/**
|
|
151
|
+
* Update the value _(based on the current value)_
|
|
152
|
+
*/
|
|
153
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
136
154
|
}
|
|
137
155
|
/**
|
|
138
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> {
|
|
@@ -19,7 +20,13 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
19
20
|
* @inheritdoc
|
|
20
21
|
*/
|
|
21
22
|
get(): Item[];
|
|
23
|
+
/**
|
|
24
|
+
* Get the value at an index
|
|
25
|
+
*/
|
|
22
26
|
get(index: number): Item | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Get the length of the array
|
|
29
|
+
*/
|
|
23
30
|
get(property: 'length'): number;
|
|
24
31
|
/**
|
|
25
32
|
* Create a computed, filtered array
|
|
@@ -48,7 +55,7 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
48
55
|
/**
|
|
49
56
|
* Set the value
|
|
50
57
|
*/
|
|
51
|
-
set(value
|
|
58
|
+
set(value?: Item[]): void;
|
|
52
59
|
/**
|
|
53
60
|
* Set the value at an index
|
|
54
61
|
*/
|
|
@@ -65,10 +72,22 @@ export declare class ReactiveArray<Item> extends Reactive<Item[], Item> {
|
|
|
65
72
|
* Remove and return items from the array _(and optionally add new items)_
|
|
66
73
|
*/
|
|
67
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;
|
|
68
83
|
/**
|
|
69
84
|
* Add items to the beginning of the array
|
|
70
85
|
*/
|
|
71
86
|
unshift(...items: Item[]): number;
|
|
87
|
+
/**
|
|
88
|
+
* Update the value _(based on the current value)_
|
|
89
|
+
*/
|
|
90
|
+
update(callback: (value: Item[]) => Item[]): void;
|
|
72
91
|
}
|
|
73
92
|
/**
|
|
74
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,13 +60,13 @@ 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
|
|
@@ -111,6 +111,22 @@ export declare class Store<Value extends PlainObject> extends Reactive<Value, Va
|
|
|
111
111
|
* Set a value by key
|
|
112
112
|
*/
|
|
113
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;
|
|
114
130
|
}
|
|
115
131
|
/**
|
|
116
132
|
* Create a reactive store
|
package/types/value/store.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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> {
|
|
4
5
|
#private;
|
|
@@ -39,6 +40,22 @@ export declare class Store<Value extends PlainObject> extends Reactive<Value, Va
|
|
|
39
40
|
* Set a value by key
|
|
40
41
|
*/
|
|
41
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;
|
|
42
59
|
}
|
|
43
60
|
/**
|
|
44
61
|
* Create a reactive store
|