@esportsplus/reactivity 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/build/system.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Computed, Signal } from './types.js';
2
2
  declare const computed: <T>(fn: Computed<T>["fn"]) => Computed<T>;
3
3
  declare const dispose: <T>(computed: Computed<T>) => void;
4
- declare const effect: <T>(fn: Computed<T>["fn"]) => void;
4
+ declare const effect: <T>(fn: Computed<T>["fn"]) => () => void;
5
5
  declare const isComputed: (value: unknown) => value is Computed<unknown>;
6
6
  declare const isSignal: (value: unknown) => value is Signal<unknown>;
7
7
  declare const onCleanup: (fn: VoidFunction) => typeof fn;
package/build/system.js CHANGED
@@ -247,7 +247,10 @@ const dispose = (computed) => {
247
247
  cleanup(computed);
248
248
  };
249
249
  const effect = (fn) => {
250
- computed(fn);
250
+ let c = computed(fn);
251
+ return () => {
252
+ dispose(c);
253
+ };
251
254
  };
252
255
  const isComputed = (value) => {
253
256
  return isObject(value) && REACTIVE in value && 'fn' in value;
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "private": false,
13
13
  "type": "module",
14
14
  "types": "build/index.d.ts",
15
- "version": "0.9.0",
15
+ "version": "0.10.0",
16
16
  "scripts": {
17
17
  "build": "tsc && tsc-alias",
18
18
  "-": "-"
package/src/system.ts CHANGED
@@ -345,7 +345,11 @@ const dispose = <T>(computed: Computed<T>) => {
345
345
  };
346
346
 
347
347
  const effect = <T>(fn: Computed<T>['fn']) => {
348
- computed(fn);
348
+ let c = computed(fn);
349
+
350
+ return () => {
351
+ dispose(c);
352
+ };
349
353
  };
350
354
 
351
355
  const isComputed = (value: unknown): value is Computed<unknown> => {