@oscarpalmer/mora 0.17.0 → 0.18.1

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.
Files changed (40) hide show
  1. package/dist/helpers/is.cjs +7 -1
  2. package/dist/helpers/is.js +8 -2
  3. package/dist/helpers/proxy.cjs +43 -0
  4. package/dist/helpers/proxy.js +43 -0
  5. package/dist/helpers/value.cjs +20 -24
  6. package/dist/helpers/value.js +20 -24
  7. package/dist/index.cjs +2 -0
  8. package/dist/index.js +3 -1
  9. package/dist/mora.full.js +107 -43
  10. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +17 -0
  11. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +17 -0
  12. package/dist/value/array.cjs +10 -16
  13. package/dist/value/array.js +11 -17
  14. package/dist/value/signal.cjs +1 -1
  15. package/dist/value/signal.js +2 -2
  16. package/dist/value/store.cjs +36 -0
  17. package/dist/value/store.js +36 -0
  18. package/package.json +1 -1
  19. package/src/helpers/is.ts +7 -1
  20. package/src/helpers/proxy.ts +71 -0
  21. package/src/helpers/value.ts +23 -33
  22. package/src/index.ts +1 -0
  23. package/src/value/array.ts +11 -30
  24. package/src/value/signal.ts +2 -2
  25. package/src/value/store.ts +90 -0
  26. package/types/helpers/is.d.ts +3 -0
  27. package/types/helpers/proxy.d.ts +5 -0
  28. package/types/helpers/value.d.ts +1 -2
  29. package/types/index.d.ts +1 -0
  30. package/types/value/store.d.ts +45 -0
  31. package/types/batch.d.cts +0 -79
  32. package/types/effect.d.cts +0 -16
  33. package/types/helpers/is.d.cts +0 -176
  34. package/types/helpers/value.d.cts +0 -72
  35. package/types/index.d.cts +0 -196
  36. package/types/subscription.d.cts +0 -71
  37. package/types/value/array.d.cts +0 -144
  38. package/types/value/computed.d.cts +0 -81
  39. package/types/value/reactive.d.cts +0 -68
  40. package/types/value/signal.d.cts +0 -87
@@ -1,5 +1,5 @@
1
1
  import { signalName } from "../helpers/is.js";
2
- import { getValue, differentValues, emitValue } from "../helpers/value.js";
2
+ import { getValue, emitValue } from "../helpers/value.js";
3
3
  import { Reactive } from "./reactive.js";
4
4
  class Signal extends Reactive {
5
5
  constructor(value, options) {
@@ -15,7 +15,7 @@ class Signal extends Reactive {
15
15
  * Set the value
16
16
  */
17
17
  set(value) {
18
- if (differentValues(this.state, this.state.value, value)) {
18
+ if (!this.state.equal(this.state.value, value)) {
19
19
  this.state.value = value;
20
20
  emitValue(this.state);
21
21
  }
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const is = require("../node_modules/@oscarpalmer/atoms/dist/internal/is.cjs");
4
+ const helpers_is = require("../helpers/is.cjs");
5
+ const helpers_proxy = require("../helpers/proxy.cjs");
6
+ const helpers_value = require("../helpers/value.cjs");
7
+ const value_reactive = require("./reactive.cjs");
8
+ class Store extends value_reactive.Reactive {
9
+ constructor(value, options) {
10
+ super(
11
+ helpers_is.storeName,
12
+ new Proxy(value, {
13
+ set: (target, property, value2) => helpers_proxy.setValueInProxy(target, property, value2, this.state, false)
14
+ }),
15
+ options
16
+ );
17
+ }
18
+ get(key) {
19
+ return is.isKey(key) ? this.state.value[key] : helpers_value.getValue(this.state);
20
+ }
21
+ peek(key) {
22
+ return is.isKey(key) ? this.state.value[key] : { ...this.state.value };
23
+ }
24
+ set(first, second) {
25
+ if (is.isKey(first)) {
26
+ this.state.value[first] = second;
27
+ } else if (first == null || is.isPlainObject(first)) {
28
+ helpers_proxy.setProxyValue(this.state.value, first ?? {});
29
+ }
30
+ }
31
+ }
32
+ function store(value, options) {
33
+ return new Store(is.isPlainObject(value) ? value : {}, options);
34
+ }
35
+ exports.Store = Store;
36
+ exports.store = store;
@@ -0,0 +1,36 @@
1
+ import { isPlainObject, isKey } from "../node_modules/@oscarpalmer/atoms/dist/internal/is.js";
2
+ import { storeName } from "../helpers/is.js";
3
+ import { setValueInProxy, setProxyValue } from "../helpers/proxy.js";
4
+ import { getValue } from "../helpers/value.js";
5
+ import { Reactive } from "./reactive.js";
6
+ class Store extends Reactive {
7
+ constructor(value, options) {
8
+ super(
9
+ storeName,
10
+ new Proxy(value, {
11
+ set: (target, property, value2) => setValueInProxy(target, property, value2, this.state, false)
12
+ }),
13
+ options
14
+ );
15
+ }
16
+ get(key) {
17
+ return isKey(key) ? this.state.value[key] : getValue(this.state);
18
+ }
19
+ peek(key) {
20
+ return isKey(key) ? this.state.value[key] : { ...this.state.value };
21
+ }
22
+ set(first, second) {
23
+ if (isKey(first)) {
24
+ this.state.value[first] = second;
25
+ } else if (first == null || isPlainObject(first)) {
26
+ setProxyValue(this.state.value, first ?? {});
27
+ }
28
+ }
29
+ }
30
+ function store(value, options) {
31
+ return new Store(isPlainObject(value) ? value : {}, options);
32
+ }
33
+ export {
34
+ Store,
35
+ store
36
+ };
package/package.json CHANGED
@@ -54,5 +54,5 @@
54
54
  },
55
55
  "type": "module",
56
56
  "types": "./types/index.d.ts",
57
- "version": "0.17.0"
57
+ "version": "0.18.1"
58
58
  }
package/src/helpers/is.ts CHANGED
@@ -4,6 +4,7 @@ import type {ReactiveArray} from '../value/array';
4
4
  import type {Computed} from '../value/computed';
5
5
  import type {Reactive} from '../value/reactive';
6
6
  import type {Signal} from '../value/signal';
7
+ import type {Store} from '../value/store';
7
8
 
8
9
  /**
9
10
  * Is the value a reactive array?
@@ -48,9 +49,14 @@ export function isSignal(value: unknown): value is Signal<unknown> {
48
49
  return isMora<Signal<unknown>>(value, signalName);
49
50
  }
50
51
 
52
+ export function isStore(value: unknown): value is Store<PlainObject> {
53
+ return isMora<Reactive<unknown>>(value, storeName);
54
+ }
55
+
51
56
  export const arrayName = 'array';
52
57
  export const computedName = 'computed';
53
58
  export const effectName = 'effect';
54
59
  export const signalName = 'signal';
60
+ export const storeName = 'store';
55
61
 
56
- const reactiveNames = new Set([arrayName, computedName, signalName]);
62
+ const reactiveNames = new Set([arrayName, computedName, signalName, storeName]);
@@ -0,0 +1,71 @@
1
+ import type {ArrayOrPlainObject, PlainObject} from '@oscarpalmer/atoms/models';
2
+ import {startBatch, stopBatch} from '../batch';
3
+ import type {ReactiveState} from '../value/reactive';
4
+ import type {Signal} from '../value/signal';
5
+ import {emitValue} from './value';
6
+
7
+ export function setProxyValue(
8
+ proxy: ArrayOrPlainObject,
9
+ value: ArrayOrPlainObject,
10
+ ): void {
11
+ startBatch();
12
+
13
+ const proxyKeys = Object.keys(proxy);
14
+ const valueKeys = Object.keys(value);
15
+
16
+ let {length} = proxyKeys;
17
+
18
+ for (let index = 0; index < length; index += 1) {
19
+ const key = proxyKeys[index];
20
+
21
+ (proxy as PlainObject)[key] = valueKeys.includes(key)
22
+ ? (value as PlainObject)[key]
23
+ : undefined;
24
+ }
25
+
26
+ length = valueKeys.length;
27
+
28
+ for (let index = 0; index < length; index += 1) {
29
+ const key = valueKeys[index];
30
+
31
+ if (!proxyKeys.includes(key)) {
32
+ const keyedValue = (value as PlainObject)[key];
33
+
34
+ (proxy as PlainObject)[key] = keyedValue;
35
+ }
36
+ }
37
+
38
+ stopBatch();
39
+ }
40
+
41
+ export function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(
42
+ target: Value,
43
+ property: PropertyKey,
44
+ value: unknown,
45
+ state: ReactiveState<Value, Equal>,
46
+ isArray: boolean,
47
+ length?: Signal<number>,
48
+ ): boolean {
49
+ if (isArray) {
50
+ const isIndex = !Number.isNaN(Number(property));
51
+ const isLength = property === 'length';
52
+
53
+ if (!isIndex && !isLength) {
54
+ return Reflect.set(target, property, value);
55
+ }
56
+ }
57
+
58
+ const previous = Reflect.get(target, property);
59
+
60
+ if (!state.equal(previous as never, value as never)) {
61
+ Reflect.set(target, property, value);
62
+
63
+ emitValue(state);
64
+
65
+ if (isArray) {
66
+ length?.set((target as unknown[]).length);
67
+ }
68
+ }
69
+
70
+ return true;
71
+ }
@@ -3,7 +3,25 @@ import {activeEffect} from '../effect';
3
3
  import {type InternalComputed, activeComputed} from '../value/computed';
4
4
  import type {ReactiveState} from '../value/reactive';
5
5
 
6
- export function differentArrays<Value>(
6
+ export function emitValue<Value>(state: ReactiveState<Value, never>): void {
7
+ for (const computed of state.computeds) {
8
+ (computed as unknown as InternalComputed).effect.dirty = true;
9
+ }
10
+
11
+ for (const effect of state.effects) {
12
+ batchedHandlers.add(effect);
13
+ }
14
+
15
+ for (const [, subscription] of state.subscriptions) {
16
+ batchedHandlers.add(subscription as never);
17
+ }
18
+
19
+ if (batchDepth === 0) {
20
+ flushHandlers();
21
+ }
22
+ }
23
+
24
+ export function equalArrays<Value>(
7
25
  state: ReactiveState<Value[], Value>,
8
26
  first: Value[],
9
27
  second: Value[],
@@ -11,7 +29,7 @@ export function differentArrays<Value>(
11
29
  let {length} = first;
12
30
 
13
31
  if (length !== second.length) {
14
- return true;
32
+ return false;
15
33
  }
16
34
 
17
35
  let offset = 0;
@@ -22,7 +40,7 @@ export function differentArrays<Value>(
22
40
 
23
41
  for (let index = 0; index < offset; index += 1) {
24
42
  if (!state.equal(first[index], second[index])) {
25
- return true;
43
+ return false;
26
44
  }
27
45
  }
28
46
  }
@@ -31,39 +49,11 @@ export function differentArrays<Value>(
31
49
 
32
50
  for (let index = offset; index < length; index += 1) {
33
51
  if (!state.equal(first[index], second[index])) {
34
- return true;
52
+ return false;
35
53
  }
36
54
  }
37
55
 
38
- return false;
39
- }
40
-
41
- export function differentValues<Value>(
42
- state: ReactiveState<Value, Value>,
43
- first: Value,
44
- second: Value,
45
- ): boolean {
46
- return Array.isArray(first) && Array.isArray(second)
47
- ? differentArrays(state as never, first, second)
48
- : !state.equal(first, second);
49
- }
50
-
51
- export function emitValue<Value>(state: ReactiveState<Value, never>): void {
52
- for (const computed of state.computeds) {
53
- (computed as unknown as InternalComputed).effect.dirty = true;
54
- }
55
-
56
- for (const effect of state.effects) {
57
- batchedHandlers.add(effect);
58
- }
59
-
60
- for (const [, subscription] of state.subscriptions) {
61
- batchedHandlers.add(subscription as never);
62
- }
63
-
64
- if (batchDepth === 0) {
65
- flushHandlers();
66
- }
56
+ return true;
67
57
  }
68
58
 
69
59
  export function getValue<Value>(state: ReactiveState<Value, never>): Value {
package/src/index.ts CHANGED
@@ -11,3 +11,4 @@ export {array, type ReactiveArray} from './value/array';
11
11
  export {computed, type Computed} from './value/computed';
12
12
  export type {Reactive} from './value/reactive';
13
13
  export {signal, type Signal} from './value/signal';
14
+ export {store, type Store} from './value/store';
@@ -1,5 +1,6 @@
1
1
  import {arrayName} from '../helpers/is';
2
- import {differentArrays, emitValue, getValue} from '../helpers/value';
2
+ import {setValueInProxy} from '../helpers/proxy';
3
+ import {emitValue, equalArrays, getValue} from '../helpers/value';
3
4
  import {type Computed, computed} from './computed';
4
5
  import {Reactive, type ReactiveOptions, type ReactiveState} from './reactive';
5
6
  import {type Signal, signal} from './signal';
@@ -36,7 +37,14 @@ export class ReactiveArray<Item> extends Reactive<Item[], Item> {
36
37
  ? updateArray(property as string, target, this.state, this.#size)
37
38
  : Reflect.get(target, property),
38
39
  set: (target, property, value) =>
39
- setValue(target, property, value, this.state, this.#size),
40
+ setValueInProxy(
41
+ target,
42
+ property,
43
+ value,
44
+ this.state,
45
+ true,
46
+ this.#size,
47
+ ),
40
48
  }),
41
49
  options,
42
50
  );
@@ -172,33 +180,6 @@ export function array<Item>(
172
180
  return new ReactiveArray(Array.isArray(value) ? value : [], options);
173
181
  }
174
182
 
175
- function setValue<Item>(
176
- target: Item[],
177
- property: PropertyKey,
178
- value: Item,
179
- state: ReactiveState<Item[], Item>,
180
- length: Signal<number>,
181
- ): boolean {
182
- const isIndex = !Number.isNaN(Number(property));
183
- const isLength = property === 'length';
184
-
185
- if (!isIndex && !isLength) {
186
- return Reflect.set(target, property, value);
187
- }
188
-
189
- const previous = Reflect.get(target, property);
190
-
191
- if (!state.equal(previous, value)) {
192
- Reflect.set(target, property, value);
193
-
194
- emitValue(state);
195
-
196
- length.set(target.length);
197
- }
198
-
199
- return true;
200
- }
201
-
202
183
  function updateArray<Item>(
203
184
  type: string,
204
185
  array: Item[],
@@ -217,7 +198,7 @@ function updateArray<Item>(
217
198
  if (
218
199
  affectsLength
219
200
  ? array.length !== previousLength
220
- : differentArrays(state, previousArray, array)
201
+ : !equalArrays(state, previousArray, array)
221
202
  ) {
222
203
  emitValue(state);
223
204
 
@@ -1,5 +1,5 @@
1
1
  import {signalName} from '../helpers/is';
2
- import {differentValues, emitValue, getValue} from '../helpers/value';
2
+ import {emitValue, getValue} from '../helpers/value';
3
3
  import {Reactive, type ReactiveOptions} from './reactive';
4
4
 
5
5
  export class Signal<Value> extends Reactive<Value> {
@@ -18,7 +18,7 @@ export class Signal<Value> extends Reactive<Value> {
18
18
  * Set the value
19
19
  */
20
20
  set(value: Value): void {
21
- if (differentValues(this.state, this.state.value, value)) {
21
+ if (!this.state.equal(this.state.value, value)) {
22
22
  this.state.value = value;
23
23
 
24
24
  emitValue(this.state);
@@ -0,0 +1,90 @@
1
+ import {isKey, isPlainObject} from '@oscarpalmer/atoms/is';
2
+ import type {Key, PlainObject} from '@oscarpalmer/atoms/models';
3
+ import {storeName} from '../helpers/is';
4
+ import {setProxyValue, setValueInProxy} from '../helpers/proxy';
5
+ import {getValue} from '../helpers/value';
6
+ import {Reactive, type ReactiveOptions} from './reactive';
7
+
8
+ export class Store<Value extends PlainObject> extends Reactive<Value, Value> {
9
+ constructor(value: Value, options?: ReactiveOptions<Value>) {
10
+ super(
11
+ storeName,
12
+ new Proxy(value, {
13
+ set: (target, property, value) =>
14
+ setValueInProxy(target, property, value, this.state, false),
15
+ }),
16
+ options,
17
+ );
18
+ }
19
+
20
+ /**
21
+ * @inheritdoc
22
+ */
23
+ get(): Value;
24
+
25
+ /**
26
+ * Get a value by key _(without reactivity)_
27
+ */
28
+ get(key: keyof Value): Value[keyof Value];
29
+
30
+ /**
31
+ * Get a value by key _(without reactivity)_
32
+ */
33
+ get(key: Key): unknown;
34
+
35
+ get(key?: unknown): unknown {
36
+ return isKey(key) ? this.state.value[key] : getValue(this.state);
37
+ }
38
+
39
+ /**
40
+ * Get the value _(without reactivity)_
41
+ */
42
+ peek(): Value;
43
+
44
+ /**
45
+ * Get a value by key _(without reactivity)_
46
+ */
47
+ peek(key: keyof Value): Value[keyof Value];
48
+
49
+ /**
50
+ * Get a value by key _(without reactivity)_
51
+ */
52
+ peek(key: Key): unknown;
53
+
54
+ peek(key?: unknown): unknown {
55
+ return isKey(key) ? this.state.value[key] : {...this.state.value};
56
+ }
57
+
58
+ /**
59
+ * Set the value
60
+ */
61
+ set(value?: Value): void;
62
+
63
+ /**
64
+ * Set a value by key
65
+ */
66
+ set(key: keyof Value, value: Value[keyof Value]): void;
67
+
68
+ /**
69
+ * Set a value by key
70
+ */
71
+ set(key: Key, value: unknown): void;
72
+
73
+ set(first?: unknown, second?: unknown): void {
74
+ if (isKey(first)) {
75
+ (this.state.value as PlainObject)[first] = second;
76
+ } else if (first == null || isPlainObject(first)) {
77
+ setProxyValue(this.state.value, first ?? {});
78
+ }
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Create a reactive store
84
+ */
85
+ export function store<Value extends PlainObject>(
86
+ value: Value,
87
+ options?: ReactiveOptions<Value>,
88
+ ): Store<Value> {
89
+ return new Store((isPlainObject(value) ? value : {}) as Value, options);
90
+ }
@@ -3,6 +3,7 @@ import type { ReactiveArray } from '../value/array';
3
3
  import type { Computed } from '../value/computed';
4
4
  import type { Reactive } from '../value/reactive';
5
5
  import type { Signal } from '../value/signal';
6
+ import type { Store } from '../value/store';
6
7
  /**
7
8
  * Is the value a reactive array?
8
9
  */
@@ -20,7 +21,9 @@ export declare function isReactive(value: unknown): value is Reactive<unknown>;
20
21
  * Is the value a signal?
21
22
  */
22
23
  export declare function isSignal(value: unknown): value is Signal<unknown>;
24
+ export declare function isStore(value: unknown): value is Store<unknown>;
23
25
  export declare const arrayName = "array";
24
26
  export declare const computedName = "computed";
25
27
  export declare const effectName = "effect";
26
28
  export declare const signalName = "signal";
29
+ export declare const storeName = "store";
@@ -0,0 +1,5 @@
1
+ import type { ArrayOrPlainObject } from '@oscarpalmer/atoms/models';
2
+ import type { ReactiveState } from '../value/reactive';
3
+ import type { Signal } from '../value/signal';
4
+ export declare function setProxyValue(proxy: ArrayOrPlainObject, value: ArrayOrPlainObject): void;
5
+ export declare function setValueInProxy<Value extends ArrayOrPlainObject, Equal>(target: Value, property: PropertyKey, value: unknown, state: ReactiveState<Value, Equal>, isArray: boolean, length?: Signal<number>): boolean;
@@ -1,5 +1,4 @@
1
1
  import type { ReactiveState } from '../value/reactive';
2
- export declare function differentArrays<Value>(state: ReactiveState<Value[], Value>, first: Value[], second: Value[]): boolean;
3
- export declare function differentValues<Value>(state: ReactiveState<Value, Value>, first: Value, second: Value): boolean;
4
2
  export declare function emitValue<Value>(state: ReactiveState<Value, never>): void;
3
+ export declare function equalArrays<Value>(state: ReactiveState<Value[], Value>, first: Value[], second: Value[]): boolean;
5
4
  export declare function getValue<Value>(state: ReactiveState<Value, never>): Value;
package/types/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export { array, type ReactiveArray } from './value/array';
5
5
  export { computed, type Computed } from './value/computed';
6
6
  export type { Reactive } from './value/reactive';
7
7
  export { signal, type Signal } from './value/signal';
8
+ export { store, type Store } from './value/store';
@@ -0,0 +1,45 @@
1
+ import type { Key, PlainObject } from '@oscarpalmer/atoms/models';
2
+ import { Reactive, type ReactiveOptions } from './reactive';
3
+ export declare class Store<Value extends PlainObject> extends Reactive<Value, Value> {
4
+ constructor(value: Value, options?: ReactiveOptions<Value>);
5
+ /**
6
+ * @inheritdoc
7
+ */
8
+ get(): Value;
9
+ /**
10
+ * Get a value by key _(without reactivity)_
11
+ */
12
+ get(key: keyof Value): Value[keyof Value];
13
+ /**
14
+ * Get a value by key _(without reactivity)_
15
+ */
16
+ get(key: Key): unknown;
17
+ /**
18
+ * Get the value _(without reactivity)_
19
+ */
20
+ peek(): Value;
21
+ /**
22
+ * Get a value by key _(without reactivity)_
23
+ */
24
+ peek(key: keyof Value): Value[keyof Value];
25
+ /**
26
+ * Get a value by key _(without reactivity)_
27
+ */
28
+ peek(key: Key): unknown;
29
+ /**
30
+ * Set the value
31
+ */
32
+ set(value?: Value): void;
33
+ /**
34
+ * Set a value by key
35
+ */
36
+ set(key: keyof Value, value: Value[keyof Value]): void;
37
+ /**
38
+ * Set a value by key
39
+ */
40
+ set(key: Key, value: unknown): void;
41
+ }
42
+ /**
43
+ * Create a reactive store
44
+ */
45
+ export declare function store<Value extends PlainObject>(value: Value, options?: ReactiveOptions<Value>): Store<Value>;
package/types/batch.d.cts DELETED
@@ -1,79 +0,0 @@
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
- declare class Computed<Value> extends Reactive<Value> {
10
- private readonly effect;
11
- constructor(callback: () => Value, options?: ReactiveOptions<Value>);
12
- /**
13
- * @inheritdoc
14
- */
15
- get(): Value;
16
- }
17
- declare abstract class Reactive<Value, Equal = Value> {
18
- protected readonly state: ReactiveState<Value, Equal>;
19
- constructor(name: string, value: Value, options?: ReactiveOptions<Equal>);
20
- /**
21
- * Get the value
22
- */
23
- abstract get(): Value;
24
- /**
25
- * Get the value _(without reactivity)_
26
- */
27
- peek(): Value;
28
- /**
29
- * Subscribe to changes
30
- */
31
- subscribe(callback: (value: Value) => void): Unsubscribe;
32
- /**
33
- * JSON representation of the value
34
- */
35
- toJSON(): Value;
36
- /**
37
- * String representation of the value
38
- */
39
- toString(): string;
40
- /**
41
- * Unsubscribe from changes
42
- */
43
- unsubscribe(callback: (value: Value) => void): void;
44
- }
45
- export type ReactiveOptions<Value> = {
46
- /**
47
- * Method to compare values for equality
48
- */
49
- equal?: (first: Value, second: Value) => boolean;
50
- };
51
- export type ReactiveState<Value, Equal> = {
52
- computeds: Set<Computed<unknown>>;
53
- effects: Set<Effect>;
54
- equal: (first: Equal, second: Equal) => boolean;
55
- subscriptions: Map<(value: Value) => void, Subscription<Value>>;
56
- value: Value;
57
- };
58
- declare class Subscription<Value> {
59
- state: ReactiveState<Value, never>;
60
- callback: GenericCallback;
61
- constructor(state: ReactiveState<Value, never>, callback: GenericCallback);
62
- }
63
- /**
64
- * Unsubscribe from changes
65
- */
66
- export type Unsubscribe = () => void;
67
- export declare function flushHandlers(): void;
68
- /**
69
- * Start batching effects _(use `stopBatch` to flush and run batched effects)_
70
- */
71
- export declare function startBatch(): void;
72
- /**
73
- * Stop batching effects and flush _(run)_ them
74
- */
75
- export declare function stopBatch(): void;
76
- export declare const batchedHandlers: Set<Effect | Subscription<unknown>>;
77
- export declare let batchDepth: number;
78
-
79
- export {};
@@ -1,16 +0,0 @@
1
- // Generated by dts-bundle-generator v9.5.1
2
-
3
- export type GenericCallback = (...args: any[]) => any;
4
- export declare class Effect {
5
- private readonly $mora;
6
- private readonly state;
7
- constructor(callback: GenericCallback);
8
- }
9
- export declare function runEffect(effect: Effect): void;
10
- /**
11
- * Create an effect
12
- */
13
- export declare function effect(callback: GenericCallback): Effect;
14
- export declare let activeEffect: Effect | undefined;
15
-
16
- export {};