@oscarpalmer/mora 0.21.0 → 0.23.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.
Files changed (70) hide show
  1. package/dist/batch.js +11 -25
  2. package/dist/constants.js +34 -0
  3. package/dist/effect.js +18 -28
  4. package/dist/helpers/is.js +9 -26
  5. package/dist/helpers/proxy.js +36 -48
  6. package/dist/helpers/value.js +21 -48
  7. package/dist/index.js +3 -16
  8. package/dist/models.js +0 -0
  9. package/dist/mora.full.js +218 -130
  10. package/dist/subscription.js +22 -28
  11. package/dist/value/array.js +97 -182
  12. package/dist/value/computed.js +33 -58
  13. package/dist/value/reactive.js +29 -53
  14. package/dist/value/signal.js +21 -33
  15. package/dist/value/store.js +37 -60
  16. package/package.json +17 -24
  17. package/src/batch.ts +11 -13
  18. package/src/constants.ts +49 -0
  19. package/src/effect.ts +11 -16
  20. package/src/helpers/is.ts +41 -19
  21. package/src/helpers/proxy.ts +34 -38
  22. package/src/helpers/value.ts +19 -14
  23. package/src/index.ts +1 -1
  24. package/src/models.ts +66 -0
  25. package/src/subscription.ts +14 -16
  26. package/src/value/array.ts +87 -45
  27. package/src/value/computed.ts +29 -39
  28. package/src/value/reactive.ts +9 -24
  29. package/src/value/signal.ts +9 -3
  30. package/src/value/store.ts +40 -9
  31. package/types/batch.d.ts +3 -5
  32. package/types/constants.d.ts +14 -0
  33. package/types/effect.d.ts +2 -1
  34. package/types/helpers/is.d.ts +23 -10
  35. package/types/helpers/proxy.d.ts +2 -3
  36. package/types/helpers/value.d.ts +1 -1
  37. package/types/index.d.ts +1 -0
  38. package/types/models.d.ts +56 -0
  39. package/types/subscription.d.ts +3 -6
  40. package/types/value/array.d.ts +48 -7
  41. package/types/value/computed.d.ts +2 -11
  42. package/types/value/reactive.d.ts +8 -17
  43. package/types/value/signal.d.ts +7 -1
  44. package/types/value/store.d.ts +28 -4
  45. package/dist/batch.cjs +0 -32
  46. package/dist/effect.cjs +0 -30
  47. package/dist/helpers/is.cjs +0 -40
  48. package/dist/helpers/proxy.cjs +0 -56
  49. package/dist/helpers/value.cjs +0 -54
  50. package/dist/index.cjs +0 -21
  51. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.cjs +0 -17
  52. package/dist/node_modules/@oscarpalmer/atoms/dist/internal/is.js +0 -17
  53. package/dist/subscription.cjs +0 -32
  54. package/dist/value/array.cjs +0 -187
  55. package/dist/value/computed.cjs +0 -60
  56. package/dist/value/reactive.cjs +0 -55
  57. package/dist/value/signal.cjs +0 -36
  58. package/dist/value/store.cjs +0 -63
  59. package/types/batch.d.cts +0 -79
  60. package/types/effect.d.cts +0 -16
  61. package/types/helpers/is.d.cts +0 -259
  62. package/types/helpers/proxy.d.cts +0 -244
  63. package/types/helpers/value.d.cts +0 -71
  64. package/types/index.d.cts +0 -281
  65. package/types/subscription.d.cts +0 -71
  66. package/types/value/array.d.cts +0 -161
  67. package/types/value/computed.d.cts +0 -81
  68. package/types/value/reactive.d.cts +0 -68
  69. package/types/value/signal.d.cts +0 -87
  70. package/types/value/store.d.cts +0 -136
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const batch = require("../batch.cjs");
4
- const effect = require("../effect.cjs");
5
- const value_computed = require("../value/computed.cjs");
6
- function emitValue(state) {
7
- for (const computed of state.computeds) {
8
- computed.effect.dirty = true;
9
- }
10
- for (const effect2 of state.effects) {
11
- batch.batchedHandlers.add(effect2);
12
- }
13
- for (const [, subscription] of state.subscriptions) {
14
- batch.batchedHandlers.add(subscription);
15
- }
16
- if (batch.batchDepth === 0) {
17
- batch.flushHandlers();
18
- }
19
- }
20
- function equalArrays(state, first, second) {
21
- let { length } = first;
22
- if (length !== second.length) {
23
- return false;
24
- }
25
- let offset = 0;
26
- if (length >= 100) {
27
- offset = Math.round(length / 10);
28
- offset = offset > 25 ? 25 : offset;
29
- for (let index = 0; index < offset; index += 1) {
30
- if (!state.equal(first[index], second[index])) {
31
- return false;
32
- }
33
- }
34
- }
35
- length -= offset;
36
- for (let index = offset; index < length; index += 1) {
37
- if (!state.equal(first[index], second[index])) {
38
- return false;
39
- }
40
- }
41
- return true;
42
- }
43
- function getValue(state) {
44
- if (value_computed.activeComputed != null) {
45
- state.computeds.add(value_computed.activeComputed);
46
- }
47
- if (effect.activeEffect != null) {
48
- state.effects.add(effect.activeEffect);
49
- }
50
- return state.value;
51
- }
52
- exports.emitValue = emitValue;
53
- exports.equalArrays = equalArrays;
54
- exports.getValue = getValue;
package/dist/index.cjs DELETED
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const batch = require("./batch.cjs");
4
- const effect = require("./effect.cjs");
5
- const helpers_is = require("./helpers/is.cjs");
6
- const value_array = require("./value/array.cjs");
7
- const value_computed = require("./value/computed.cjs");
8
- const value_signal = require("./value/signal.cjs");
9
- const value_store = require("./value/store.cjs");
10
- exports.startBatch = batch.startBatch;
11
- exports.stopBatch = batch.stopBatch;
12
- exports.effect = effect.effect;
13
- exports.isArray = helpers_is.isArray;
14
- exports.isComputed = helpers_is.isComputed;
15
- exports.isEffect = helpers_is.isEffect;
16
- exports.isReactive = helpers_is.isReactive;
17
- exports.isSignal = helpers_is.isSignal;
18
- exports.array = value_array.array;
19
- exports.computed = value_computed.computed;
20
- exports.signal = value_signal.signal;
21
- exports.store = value_store.store;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- function isKey(value) {
4
- return typeof value === "number" || typeof value === "string";
5
- }
6
- function isPlainObject(value) {
7
- if (value === null || typeof value !== "object") {
8
- return false;
9
- }
10
- if (Symbol.toStringTag in value || Symbol.iterator in value) {
11
- return false;
12
- }
13
- const prototype = Object.getPrototypeOf(value);
14
- return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
15
- }
16
- exports.isKey = isKey;
17
- exports.isPlainObject = isPlainObject;
@@ -1,17 +0,0 @@
1
- function isKey(value) {
2
- return typeof value === "number" || typeof value === "string";
3
- }
4
- function isPlainObject(value) {
5
- if (value === null || typeof value !== "object") {
6
- return false;
7
- }
8
- if (Symbol.toStringTag in value || Symbol.iterator in value) {
9
- return false;
10
- }
11
- const prototype = Object.getPrototypeOf(value);
12
- return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
13
- }
14
- export {
15
- isKey,
16
- isPlainObject
17
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- class Subscription {
4
- constructor(state, callback) {
5
- this.state = state;
6
- this.callback = callback;
7
- callback(state.value);
8
- }
9
- }
10
- function noop() {
11
- }
12
- function subscribe(state, callback) {
13
- if (typeof callback !== "function" || state.subscriptions.has(callback)) {
14
- return noop;
15
- }
16
- state.subscriptions.set(callback, new Subscription(state, callback));
17
- return () => {
18
- unsubscribe(state, callback);
19
- };
20
- }
21
- function unsubscribe(state, callback) {
22
- const subscription = state.subscriptions.get(callback);
23
- state.subscriptions.delete(callback);
24
- if (subscription != null) {
25
- subscription.callback = noop;
26
- subscription.state = void 0;
27
- }
28
- }
29
- exports.Subscription = Subscription;
30
- exports.noop = noop;
31
- exports.subscribe = subscribe;
32
- exports.unsubscribe = unsubscribe;
@@ -1,187 +0,0 @@
1
- "use strict";
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8
- var _indiced, _size;
9
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
10
- const helpers_is = require("../helpers/is.cjs");
11
- const helpers_proxy = require("../helpers/proxy.cjs");
12
- const helpers_value = require("../helpers/value.cjs");
13
- const subscription = require("../subscription.cjs");
14
- const value_computed = require("./computed.cjs");
15
- const value_reactive = require("./reactive.cjs");
16
- const value_signal = require("./signal.cjs");
17
- class ReactiveArray extends value_reactive.Reactive {
18
- constructor(value, options) {
19
- super(
20
- helpers_is.arrayName,
21
- new Proxy(value, {
22
- get: (target, property) => updateMethods.has(property) ? updateArray(property, target, this.state, __privateGet(this, _size)) : Reflect.get(target, property),
23
- set: (target, property, value2) => helpers_proxy.setValueInProxy(
24
- target,
25
- property,
26
- value2,
27
- this.state,
28
- true,
29
- __privateGet(this, _size)
30
- )
31
- }),
32
- options
33
- );
34
- __privateAdd(this, _indiced, /* @__PURE__ */ new Map());
35
- __privateAdd(this, _size, value_signal.signal(0));
36
- __privateGet(this, _size).set(value.length);
37
- }
38
- /**
39
- * The length of the array
40
- */
41
- get length() {
42
- return __privateGet(this, _size).get();
43
- }
44
- /**
45
- * Set the length of the array
46
- */
47
- set length(value) {
48
- if (typeof value === "number" && value >= 0 && value !== this.state.value.length) {
49
- this.get().length = value;
50
- }
51
- }
52
- /**
53
- * Clear the array
54
- */
55
- clear() {
56
- this.length = 0;
57
- }
58
- get(first) {
59
- if (typeof first === "number") {
60
- return helpers_proxy.getReactiveValueInProxy(this, __privateGet(this, _indiced), first, true).get();
61
- }
62
- if (first === "length") {
63
- return this.length;
64
- }
65
- return helpers_value.getValue(this.state);
66
- }
67
- /**
68
- * Create a computed, filtered array
69
- */
70
- filter(callback) {
71
- return value_computed.computed(() => this.get().filter(callback));
72
- }
73
- /**
74
- * Create a computed, mapped array
75
- */
76
- map(callback) {
77
- return value_computed.computed(() => this.get().map(callback));
78
- }
79
- peek(value) {
80
- if (value === true) {
81
- return __privateGet(this, _size).peek();
82
- }
83
- if (typeof value === "number") {
84
- return this.state.value.at(value);
85
- }
86
- return [...this.state.value];
87
- }
88
- /**
89
- * Remove and return the last item of the array
90
- */
91
- pop() {
92
- return this.state.value.pop();
93
- }
94
- /**
95
- * Add items to the end of the array
96
- */
97
- push(...items) {
98
- return this.state.value.push(...items);
99
- }
100
- set(first, second) {
101
- if (first == null || Array.isArray(first)) {
102
- this.state.value.splice(0, this.state.value.length, ...first ?? []);
103
- } else if (first === "length") {
104
- this.length = second;
105
- } else if (typeof first === "number") {
106
- this.state.value[first] = second;
107
- }
108
- }
109
- /**
110
- * Remove and return the first item of the array
111
- */
112
- shift() {
113
- return this.state.value.shift();
114
- }
115
- /**
116
- * Remove and return items from the array _(and optionally add new items)_
117
- */
118
- splice(from, to, ...items) {
119
- return this.state.value.splice(
120
- from,
121
- to ?? this.state.value.length,
122
- ...items
123
- );
124
- }
125
- subscribe(first, second) {
126
- if (typeof first === "number" && typeof second === "function") {
127
- return helpers_proxy.getReactiveValueInProxy(
128
- this,
129
- __privateGet(this, _indiced),
130
- first,
131
- true
132
- ).subscribe(second);
133
- }
134
- return typeof first === "function" ? subscription.subscribe(this.state, first) : subscription.noop;
135
- }
136
- /**
137
- * Add items to the beginning of the array
138
- */
139
- unshift(...items) {
140
- return this.state.value.unshift(...items);
141
- }
142
- /**
143
- * Update the value _(based on the current value)_
144
- */
145
- update(callback) {
146
- const updated = callback(this.state.value);
147
- if (updated == null || Array.isArray(updated)) {
148
- this.set(updated);
149
- }
150
- }
151
- }
152
- _indiced = new WeakMap();
153
- _size = new WeakMap();
154
- function array(value, options) {
155
- return new ReactiveArray(Array.isArray(value) ? value : [], options);
156
- }
157
- function updateArray(type, array2, state, length) {
158
- const affectsLength = lengthAffectingMethods.has(type);
159
- const previousArray = affectsLength ? [] : [...array2];
160
- const previousLength = array2.length;
161
- return (...args) => {
162
- const result = array2[type](
163
- ...args
164
- );
165
- if (affectsLength ? array2.length !== previousLength : !helpers_value.equalArrays(state, previousArray, array2)) {
166
- helpers_value.emitValue(state);
167
- length.set(array2.length);
168
- }
169
- return result;
170
- };
171
- }
172
- const lengthAffectingMethods = /* @__PURE__ */ new Set([
173
- "pop",
174
- "push",
175
- "shift",
176
- "unshift"
177
- ]);
178
- const updateMethods = /* @__PURE__ */ new Set([
179
- ...lengthAffectingMethods,
180
- "copyWithin",
181
- "fill",
182
- "reverse",
183
- "sort",
184
- "splice"
185
- ]);
186
- exports.ReactiveArray = ReactiveArray;
187
- exports.array = array;
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const batch = require("../batch.cjs");
7
- const effect = require("../effect.cjs");
8
- const helpers_is = require("../helpers/is.cjs");
9
- const value_reactive = require("./reactive.cjs");
10
- exports.activeComputed = void 0;
11
- class Computed extends value_reactive.Reactive {
12
- constructor(callback, options) {
13
- super(helpers_is.computedName, void 0, options);
14
- __publicField(this, "effect", {
15
- dirty: true,
16
- instance: void 0
17
- });
18
- this.effect.instance = effect.effect(() => {
19
- if (this.effect.dirty) {
20
- const previousComputed = exports.activeComputed;
21
- exports.activeComputed = this;
22
- const value = callback();
23
- exports.activeComputed = previousComputed;
24
- if (!this.state.equal(this.state.value, value)) {
25
- this.state.value = value;
26
- for (const computed2 of this.state.computeds) {
27
- computed2.effect.dirty = true;
28
- }
29
- for (const effect2 of this.state.effects) {
30
- batch.batchedHandlers.add(effect2);
31
- }
32
- for (const [, subscription] of this.state.subscriptions) {
33
- subscription.callback(value);
34
- }
35
- }
36
- this.effect.dirty = false;
37
- }
38
- });
39
- }
40
- /**
41
- * @inheritdoc
42
- */
43
- get() {
44
- if (exports.activeComputed != null && this !== exports.activeComputed) {
45
- this.state.computeds.add(exports.activeComputed);
46
- }
47
- if (effect.activeEffect != null && effect.activeEffect !== this.effect.instance) {
48
- this.state.effects.add(effect.activeEffect);
49
- }
50
- if (this.effect.dirty && batch.batchDepth === 0) {
51
- effect.runEffect(this.effect.instance);
52
- }
53
- return this.state.value;
54
- }
55
- }
56
- function computed(callback, options) {
57
- return new Computed(callback, options);
58
- }
59
- exports.Computed = Computed;
60
- exports.computed = computed;
@@ -1,55 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
6
- const subscription = require("../subscription.cjs");
7
- class Reactive {
8
- constructor(name, value, options) {
9
- __publicField(this, "state", {
10
- computeds: /* @__PURE__ */ new Set(),
11
- effects: /* @__PURE__ */ new Set(),
12
- equal: Object.is,
13
- subscriptions: /* @__PURE__ */ new Map(),
14
- value: void 0
15
- });
16
- this.state.value = value;
17
- if (typeof options === "object" && typeof options.equal === "function") {
18
- this.state.equal = options.equal;
19
- }
20
- Object.defineProperty(this, "$mora", {
21
- value: name
22
- });
23
- }
24
- /**
25
- * Get the value _(without reactivity)_
26
- */
27
- peek() {
28
- return this.state.value;
29
- }
30
- /**
31
- * Subscribe to changes
32
- */
33
- subscribe(callback) {
34
- return subscription.subscribe(this.state, callback);
35
- }
36
- /**
37
- * JSON representation of the value
38
- */
39
- toJSON() {
40
- return this.get();
41
- }
42
- /**
43
- * String representation of the value
44
- */
45
- toString() {
46
- return String(this.get());
47
- }
48
- /**
49
- * Unsubscribe from changes
50
- */
51
- unsubscribe(callback) {
52
- subscription.unsubscribe(this.state, callback);
53
- }
54
- }
55
- exports.Reactive = Reactive;
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const helpers_is = require("../helpers/is.cjs");
4
- const helpers_value = require("../helpers/value.cjs");
5
- const value_reactive = require("./reactive.cjs");
6
- class Signal extends value_reactive.Reactive {
7
- constructor(value, options) {
8
- super(helpers_is.signalName, value, options);
9
- }
10
- /**
11
- * @inheritdoc
12
- */
13
- get() {
14
- return helpers_value.getValue(this.state);
15
- }
16
- /**
17
- * Set the value
18
- */
19
- set(value) {
20
- if (!this.state.equal(this.state.value, value)) {
21
- this.state.value = value;
22
- helpers_value.emitValue(this.state);
23
- }
24
- }
25
- /**
26
- * Update the value _(based on the current value)_
27
- */
28
- update(callback) {
29
- this.set(callback(this.state.value));
30
- }
31
- }
32
- function signal(value, options) {
33
- return new Signal(value, options);
34
- }
35
- exports.Signal = Signal;
36
- exports.signal = signal;
@@ -1,63 +0,0 @@
1
- "use strict";
2
- var __typeError = (msg) => {
3
- throw TypeError(msg);
4
- };
5
- var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
6
- var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
7
- var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
8
- var _keyed;
9
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
10
- const is = require("../node_modules/@oscarpalmer/atoms/dist/internal/is.cjs");
11
- const helpers_is = require("../helpers/is.cjs");
12
- const helpers_proxy = require("../helpers/proxy.cjs");
13
- const helpers_value = require("../helpers/value.cjs");
14
- const subscription = require("../subscription.cjs");
15
- const value_reactive = require("./reactive.cjs");
16
- class Store extends value_reactive.Reactive {
17
- constructor(value, options) {
18
- super(
19
- helpers_is.storeName,
20
- new Proxy(value, {
21
- set: (target, property, value2) => helpers_proxy.setValueInProxy(target, property, value2, this.state, false)
22
- }),
23
- options
24
- );
25
- __privateAdd(this, _keyed, /* @__PURE__ */ new Map());
26
- }
27
- get(key) {
28
- return is.isKey(key) ? helpers_proxy.getReactiveValueInProxy(this, __privateGet(this, _keyed), key, false).get() : helpers_value.getValue(this.state);
29
- }
30
- peek(key) {
31
- return is.isKey(key) ? this.state.value[key] : { ...this.state.value };
32
- }
33
- set(first, second) {
34
- if (is.isKey(first)) {
35
- this.state.value[first] = second;
36
- } else if (first == null || is.isPlainObject(first)) {
37
- helpers_proxy.setProxyValue(this.state.value, first ?? {});
38
- }
39
- }
40
- subscribe(first, second) {
41
- if (is.isKey(first) && typeof second === "function") {
42
- return helpers_proxy.getReactiveValueInProxy(this, __privateGet(this, _keyed), first, false).subscribe(
43
- second
44
- );
45
- }
46
- return typeof first === "function" ? subscription.subscribe(this.state, first) : subscription.noop;
47
- }
48
- /**
49
- * Update the value _(based on the current value)_
50
- */
51
- update(callback) {
52
- const updated = callback({ ...this.state.value });
53
- if (updated == null || is.isPlainObject(updated)) {
54
- helpers_proxy.setProxyValue(this.state.value, updated ?? {});
55
- }
56
- }
57
- }
58
- _keyed = new WeakMap();
59
- function store(value, options) {
60
- return new Store(is.isPlainObject(value) ? value : {}, options);
61
- }
62
- exports.Store = Store;
63
- exports.store = store;
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<GenericCallback, Subscription>;
56
- value: Value;
57
- };
58
- declare class Subscription {
59
- state: ReactiveState<unknown, never>;
60
- callback: GenericCallback;
61
- constructor(state: ReactiveState<unknown, 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>;
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 {};