@esportsplus/reactivity 0.1.11 → 0.1.13

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/signal.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Changed, Event, Function, Listener, NeverAsync, Options, State, Type } from './types';
1
+ import { Changed, Event, Function, Listener, NeverAsync, Options, Scheduler, State, Type } from './types';
2
2
  declare class Core<T> {
3
3
  listeners: Record<Event, (Listener<any> | null)[]> | null;
4
4
  observers: Core<any>[] | null;
@@ -28,9 +28,9 @@ declare class Effect extends Core<null> {
28
28
  get type(): Type;
29
29
  }
30
30
  declare class Root extends Core<null> {
31
- scheduler: (fn: Function) => unknown;
31
+ scheduler: Scheduler;
32
32
  tracking: boolean;
33
- constructor(scheduler: Root['scheduler'], tracking: boolean);
33
+ constructor(scheduler: Scheduler, tracking: boolean);
34
34
  get type(): Type;
35
35
  }
36
36
  declare class Signal<T> extends Core<T> {
@@ -45,7 +45,7 @@ declare const dispose: <T extends {
45
45
  dispose: VoidFunction;
46
46
  }>(dispose?: T | T[] | null | undefined) => T | T[] | null | undefined;
47
47
  declare const effect: (fn: Effect['fn']) => Effect;
48
- declare const root: <T>(fn: (root: Root) => T, scheduler?: Root['scheduler']) => T;
48
+ declare const root: <T>(fn: (root: Root) => T, scheduler?: Scheduler) => T;
49
49
  declare const signal: <T>(value: T, options?: Options) => Signal<T>;
50
50
  export { computed, dispose, effect, root, signal };
51
- export { Computed, Effect, Signal };
51
+ export { Computed, Effect, Root, Signal };
package/build/signal.js CHANGED
@@ -318,4 +318,4 @@ const signal = (value, options) => {
318
318
  return new Signal(value, options);
319
319
  };
320
320
  export { computed, dispose, effect, root, signal };
321
- export { Computed, Effect, Signal };
321
+ export { Computed, Effect, Root, Signal };
package/build/types.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Function, NeverAsync, Prettify } from '@esportsplus/typescript';
2
2
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
3
- import { Computed, Effect, Signal } from './signal';
3
+ import { Computed, Effect, Root, Signal } from './signal';
4
4
  type Changed = (a: unknown, b: unknown) => boolean;
5
5
  type Event = string;
6
6
  type Listener<D> = {
@@ -14,6 +14,7 @@ type Object = Record<PropertyKey, unknown>;
14
14
  type Options = {
15
15
  changed?: Changed;
16
16
  };
17
+ type Scheduler = (fn: Function) => unknown;
17
18
  type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
18
19
  type Type = typeof COMPUTED | typeof EFFECT | typeof ROOT | typeof SIGNAL;
19
- export { Changed, Computed, Effect, Event, Function, Listener, Object, Options, NeverAsync, Prettify, Signal, State, Type };
20
+ export type { Changed, Computed, Effect, Event, Function, Listener, Object, Options, NeverAsync, Prettify, Root, Scheduler, Signal, State, Type };
package/build/types.js CHANGED
@@ -1,2 +1 @@
1
- import { Computed, Effect, Signal } from './signal';
2
- export { Computed, Effect, Signal };
1
+ export {};
package/package.json CHANGED
@@ -16,5 +16,5 @@
16
16
  "prepublishOnly": "npm run build"
17
17
  },
18
18
  "types": "build/index.d.ts",
19
- "version": "0.1.11"
19
+ "version": "0.1.13"
20
20
  }
package/src/signal.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
2
- import { Changed, Event, Function, Listener, NeverAsync, Options, State, Type } from './types';
2
+ import { Changed, Event, Function, Listener, NeverAsync, Options, Scheduler, State, Type } from './types';
3
3
  import { isArray } from './utilities';
4
4
 
5
5
 
@@ -172,11 +172,11 @@ class Effect extends Core<null> {
172
172
  }
173
173
 
174
174
  class Root extends Core<null> {
175
- scheduler: (fn: Function) => unknown;
175
+ scheduler: Scheduler;
176
176
  tracking: boolean;
177
177
 
178
178
 
179
- constructor(scheduler: Root['scheduler'], tracking: boolean) {
179
+ constructor(scheduler: Scheduler, tracking: boolean) {
180
180
  super(CLEAN, null);
181
181
  this.scheduler = scheduler;
182
182
  this.tracking = tracking;
@@ -400,7 +400,7 @@ const effect = (fn: Effect['fn']) => {
400
400
  return new Effect(fn);
401
401
  };
402
402
 
403
- const root = <T>(fn: NeverAsync<(root: Root) => T>, scheduler?: Root['scheduler']) => {
403
+ const root = <T>(fn: NeverAsync<(root: Root) => T>, scheduler?: Scheduler) => {
404
404
  let o = observer,
405
405
  s = scope;
406
406
 
@@ -429,4 +429,4 @@ const signal = <T>(value: T, options?: Options) => {
429
429
 
430
430
 
431
431
  export { computed, dispose, effect, root, signal };
432
- export { Computed, Effect, Signal };
432
+ export { Computed, Effect, Root, Signal };
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Function, NeverAsync, Prettify } from '@esportsplus/typescript'
2
2
  import { CHECK, CLEAN, COMPUTED, DIRTY, DISPOSED, EFFECT, ROOT, SIGNAL } from './constants';
3
- import { Computed, Effect, Signal } from './signal';
3
+ import { Computed, Effect, Root, Signal } from './signal';
4
4
 
5
5
 
6
6
  type Changed = (a: unknown, b: unknown) => boolean;
@@ -19,9 +19,11 @@ type Options = {
19
19
  changed?: Changed;
20
20
  };
21
21
 
22
+ type Scheduler = (fn: Function) => unknown;
23
+
22
24
  type State = typeof CHECK | typeof CLEAN | typeof DIRTY | typeof DISPOSED;
23
25
 
24
26
  type Type = typeof COMPUTED | typeof EFFECT | typeof ROOT | typeof SIGNAL;
25
27
 
26
28
 
27
- export { Changed, Computed, Effect, Event, Function, Listener, Object, Options, NeverAsync, Prettify, Signal, State, Type };
29
+ export type { Changed, Computed, Effect, Event, Function, Listener, Object, Options, NeverAsync, Prettify, Root, Scheduler, Signal, State, Type };