@oscarpalmer/mora 0.9.0 → 0.10.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/types/is.d.cts CHANGED
@@ -1,9 +1,15 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
- declare class Signal<Value> {
3
+ export type GenericCallback = (...args: any[]) => any;
4
+ declare class Effect {
4
5
  private readonly $mora;
5
6
  private readonly state;
6
- constructor(value: Value);
7
+ constructor(callback: GenericCallback);
8
+ }
9
+ declare class Computed<Value> {
10
+ private readonly $mora;
11
+ private readonly state;
12
+ constructor(callback: () => Value);
7
13
  /**
8
14
  * Get the value
9
15
  */
@@ -13,24 +19,18 @@ declare class Signal<Value> {
13
19
  */
14
20
  peek(): Value;
15
21
  /**
16
- * Set the value
22
+ * Subscribe to changes
17
23
  */
18
- set(value: Value): void;
24
+ subscribe(callback: (value: Value) => void): Unsubscribe;
19
25
  /**
20
- * Update the value
26
+ * Unsubscribe from changes
21
27
  */
22
- update(callback: (value: Value) => Value): void;
23
- }
24
- export type GenericCallback = (...args: any[]) => any;
25
- declare class Effect {
26
- private readonly $mora;
27
- private readonly state;
28
- constructor(callback: GenericCallback);
28
+ unsubscribe(callback: (value: Value) => void): void;
29
29
  }
30
- declare class Computed<Value> {
30
+ declare class Signal<Value> {
31
31
  private readonly $mora;
32
32
  private readonly state;
33
- constructor(callback: () => Value);
33
+ constructor(value: Value);
34
34
  /**
35
35
  * Get the value
36
36
  */
@@ -39,7 +39,24 @@ declare class Computed<Value> {
39
39
  * Get the value _(without reactivity)_
40
40
  */
41
41
  peek(): Value;
42
+ /**
43
+ * Set the value
44
+ */
45
+ set(value: Value): void;
46
+ /**
47
+ * Subscribe to changes
48
+ */
49
+ subscribe(callback: (value: Value) => void): Unsubscribe;
50
+ /**
51
+ * Unsubscribe from changes
52
+ */
53
+ unsubscribe(callback: (value: Value) => void): void;
54
+ /**
55
+ * Update the value
56
+ */
57
+ update(callback: (value: Value) => Value): void;
42
58
  }
59
+ export type Unsubscribe = () => void;
43
60
  /**
44
61
  * Is the value a computed signal?
45
62
  */
@@ -1,5 +1,46 @@
1
1
  // Generated by dts-bundle-generator v9.5.1
2
2
 
3
+ export type GenericCallback = (...args: any[]) => any;
4
+ declare class Effect {
5
+ private readonly $mora;
6
+ private readonly state;
7
+ constructor(callback: GenericCallback);
8
+ }
9
+ export type ComputedState<Value> = {
10
+ computeds: Set<Computed<unknown>>;
11
+ dirty: boolean;
12
+ effect: Effect;
13
+ effects: Set<Effect>;
14
+ subscriptions: Map<GenericCallback, Subscription>;
15
+ value: Value;
16
+ };
17
+ declare class Computed<Value> {
18
+ private readonly $mora;
19
+ private readonly state;
20
+ constructor(callback: () => Value);
21
+ /**
22
+ * Get the value
23
+ */
24
+ get(): Value;
25
+ /**
26
+ * Get the value _(without reactivity)_
27
+ */
28
+ peek(): Value;
29
+ /**
30
+ * Subscribe to changes
31
+ */
32
+ subscribe(callback: (value: Value) => void): Unsubscribe;
33
+ /**
34
+ * Unsubscribe from changes
35
+ */
36
+ unsubscribe(callback: (value: Value) => void): void;
37
+ }
38
+ export type SignalState<Value> = {
39
+ computeds: Set<Computed<unknown>>;
40
+ effects: Set<Effect>;
41
+ subscriptions: Map<GenericCallback, Subscription>;
42
+ value: Value;
43
+ };
3
44
  export declare class Signal<Value> {
4
45
  private readonly $mora;
5
46
  private readonly state;
@@ -16,11 +57,25 @@ export declare class Signal<Value> {
16
57
  * Set the value
17
58
  */
18
59
  set(value: Value): void;
60
+ /**
61
+ * Subscribe to changes
62
+ */
63
+ subscribe(callback: (value: Value) => void): Unsubscribe;
64
+ /**
65
+ * Unsubscribe from changes
66
+ */
67
+ unsubscribe(callback: (value: Value) => void): void;
19
68
  /**
20
69
  * Update the value
21
70
  */
22
71
  update(callback: (value: Value) => Value): void;
23
72
  }
24
73
  export declare function signal<Value>(value: Value): Signal<Value>;
74
+ declare class Subscription {
75
+ state: ComputedState<unknown> | SignalState<unknown>;
76
+ callback: GenericCallback;
77
+ constructor(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback);
78
+ }
79
+ export type Unsubscribe = () => void;
25
80
 
26
81
  export {};
package/types/signal.d.ts CHANGED
@@ -1,3 +1,13 @@
1
+ import type { GenericCallback } from '@oscarpalmer/atoms/models';
2
+ import { type Computed } from './computed';
3
+ import { type Effect } from './effect';
4
+ import { type Subscription, type Unsubscribe } from './subscription';
5
+ export type SignalState<Value> = {
6
+ computeds: Set<Computed<unknown>>;
7
+ effects: Set<Effect>;
8
+ subscriptions: Map<GenericCallback, Subscription>;
9
+ value: Value;
10
+ };
1
11
  export declare class Signal<Value> {
2
12
  private readonly $mora;
3
13
  private readonly state;
@@ -14,6 +24,14 @@ export declare class Signal<Value> {
14
24
  * Set the value
15
25
  */
16
26
  set(value: Value): void;
27
+ /**
28
+ * Subscribe to changes
29
+ */
30
+ subscribe(callback: (value: Value) => void): Unsubscribe;
31
+ /**
32
+ * Unsubscribe from changes
33
+ */
34
+ unsubscribe(callback: (value: Value) => void): void;
17
35
  /**
18
36
  * Update the value
19
37
  */
@@ -0,0 +1,54 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export type GenericCallback = (...args: any[]) => any;
4
+ declare class Effect {
5
+ private readonly $mora;
6
+ private readonly state;
7
+ constructor(callback: GenericCallback);
8
+ }
9
+ export type ComputedState<Value> = {
10
+ computeds: Set<Computed<unknown>>;
11
+ dirty: boolean;
12
+ effect: Effect;
13
+ effects: Set<Effect>;
14
+ subscriptions: Map<GenericCallback, Subscription>;
15
+ value: Value;
16
+ };
17
+ declare class Computed<Value> {
18
+ private readonly $mora;
19
+ private readonly state;
20
+ constructor(callback: () => Value);
21
+ /**
22
+ * Get the value
23
+ */
24
+ get(): Value;
25
+ /**
26
+ * Get the value _(without reactivity)_
27
+ */
28
+ peek(): Value;
29
+ /**
30
+ * Subscribe to changes
31
+ */
32
+ subscribe(callback: (value: Value) => void): Unsubscribe;
33
+ /**
34
+ * Unsubscribe from changes
35
+ */
36
+ unsubscribe(callback: (value: Value) => void): void;
37
+ }
38
+ export type SignalState<Value> = {
39
+ computeds: Set<Computed<unknown>>;
40
+ effects: Set<Effect>;
41
+ subscriptions: Map<GenericCallback, Subscription>;
42
+ value: Value;
43
+ };
44
+ export declare class Subscription {
45
+ state: ComputedState<unknown> | SignalState<unknown>;
46
+ callback: GenericCallback;
47
+ constructor(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback);
48
+ }
49
+ export type Unsubscribe = () => void;
50
+ export declare function noop(): void;
51
+ export declare function subscribe(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback): Unsubscribe;
52
+ export declare function unsubscribe(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback): void;
53
+
54
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { GenericCallback } from '@oscarpalmer/atoms/models';
2
+ import type { ComputedState } from './computed';
3
+ import type { SignalState } from './signal';
4
+ export declare class Subscription {
5
+ state: ComputedState<unknown> | SignalState<unknown>;
6
+ callback: GenericCallback;
7
+ constructor(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback);
8
+ }
9
+ export type Unsubscribe = () => void;
10
+ export declare function noop(): void;
11
+ export declare function subscribe(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback): Unsubscribe;
12
+ export declare function unsubscribe(state: ComputedState<unknown> | SignalState<unknown>, callback: GenericCallback): void;