@esportsplus/reactivity 0.13.0 → 0.13.2
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/build/reactive/array.d.ts +35 -0
- package/build/reactive/index.d.ts +0 -1
- package/build/types.d.ts +2 -1
- package/package.json +1 -1
- package/src/reactive/array.ts +5 -0
- package/src/reactive/index.ts +1 -2
- package/src/types.ts +2 -1
|
@@ -2,6 +2,41 @@ import { Infer } from '../types.js';
|
|
|
2
2
|
type API<T> = Infer<T[]> & {
|
|
3
3
|
clear: () => void;
|
|
4
4
|
dispose: () => void;
|
|
5
|
+
dispatch: <T, K extends keyof Events<T>, V>(event: K, value?: V) => void;
|
|
6
|
+
map: <T, R>(this: API<T>, fn: (this: API<T>, value: T, i: number) => R, i?: number, n?: number) => R[];
|
|
7
|
+
on: <T, K extends keyof Events<T>>(event: K, listener: Listener<Events<T>[K]>) => void;
|
|
8
|
+
once: <T, K extends keyof Events<T>>(event: K, listener: Listener<Events<T>[K]>) => void;
|
|
9
|
+
};
|
|
10
|
+
type Events<T> = {
|
|
11
|
+
clear: undefined;
|
|
12
|
+
pop: {
|
|
13
|
+
item: T;
|
|
14
|
+
};
|
|
15
|
+
push: {
|
|
16
|
+
items: T[];
|
|
17
|
+
};
|
|
18
|
+
reverse: undefined;
|
|
19
|
+
set: {
|
|
20
|
+
index: number;
|
|
21
|
+
item: T;
|
|
22
|
+
};
|
|
23
|
+
shift: {
|
|
24
|
+
item: T;
|
|
25
|
+
};
|
|
26
|
+
sort: undefined;
|
|
27
|
+
splice: {
|
|
28
|
+
deleteCount: number;
|
|
29
|
+
items: T[];
|
|
30
|
+
start: number;
|
|
31
|
+
};
|
|
32
|
+
unshift: {
|
|
33
|
+
items: T[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
type Listener<V> = {
|
|
37
|
+
once?: boolean;
|
|
38
|
+
(value: V): void;
|
|
5
39
|
};
|
|
6
40
|
declare const _default: <T>(data: T[]) => API<T>;
|
|
7
41
|
export default _default;
|
|
42
|
+
export type { API as ReactiveArray };
|
package/build/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { COMPUTED, SIGNAL, STATE_CHECK, STATE_DIRTY, STATE_IN_HEAP, STATE_NONE, STATE_RECOMPUTING } from './constants.js';
|
|
2
|
+
import { ReactiveArray } from './reactive/array.js';
|
|
2
3
|
import { ReactiveObject } from './reactive/object.js';
|
|
3
4
|
interface Computed<T> {
|
|
4
5
|
[COMPUTED]: true;
|
|
@@ -31,4 +32,4 @@ type Signal<T> = {
|
|
|
31
32
|
subsTail: Link | null;
|
|
32
33
|
value: T;
|
|
33
34
|
};
|
|
34
|
-
export type { Computed, Infer, Link, Signal, ReactiveObject };
|
|
35
|
+
export type { Computed, Infer, Link, Signal, ReactiveArray, ReactiveObject };
|
package/package.json
CHANGED
package/src/reactive/array.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { isReactiveObject } from './object';
|
|
|
8
8
|
type API<T> = Infer<T[]> & {
|
|
9
9
|
clear: () => void;
|
|
10
10
|
dispose: () => void;
|
|
11
|
+
dispatch: <T, K extends keyof Events<T>, V>(event: K, value?: V) => void;
|
|
12
|
+
map: <T, R>(this: API<T>, fn: (this: API<T>, value: T, i: number) => R, i?: number, n?: number) => R[];
|
|
13
|
+
on: <T, K extends keyof Events<T>>(event: K, listener: Listener<Events<T>[K]>) => void;
|
|
14
|
+
once: <T, K extends keyof Events<T>>(event: K, listener: Listener<Events<T>[K]>) => void;
|
|
11
15
|
};
|
|
12
16
|
|
|
13
17
|
type Events<T> = {
|
|
@@ -327,3 +331,4 @@ export default <T>(data: T[]) => {
|
|
|
327
331
|
|
|
328
332
|
return proxy;
|
|
329
333
|
};
|
|
334
|
+
export type { API as ReactiveArray };
|
package/src/reactive/index.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { COMPUTED, SIGNAL, STATE_CHECK, STATE_DIRTY, STATE_IN_HEAP, STATE_NONE, STATE_RECOMPUTING } from './constants';
|
|
2
|
+
import { ReactiveArray } from './reactive/array';
|
|
2
3
|
import { ReactiveObject } from './reactive/object';
|
|
3
4
|
|
|
4
5
|
|
|
@@ -57,5 +58,5 @@ export type {
|
|
|
57
58
|
Infer,
|
|
58
59
|
Link,
|
|
59
60
|
Signal,
|
|
60
|
-
ReactiveObject
|
|
61
|
+
ReactiveArray, ReactiveObject
|
|
61
62
|
};
|