| 2 | import type { AnyStore, Store, StoreValue } from '../index.js' |
| 3 | |
| 4 | interface Effect { |
| 5 | <OriginStore extends Store>( |
| 6 | stores: OriginStore, |
| 7 | cb: (value: StoreValue<OriginStore>) => (() => void) | void |
| 8 | ): () => void |
| 9 | /** |
| 10 | * Subscribe for multiple stores. Also you can define cleanup function |
| 11 | * to call on stores changes. |
| 12 | * |
| 13 | * ```js |
| 14 | * const $enabled = atom(true) |
| 15 | * const $interval = atom(1000) |
| 16 | * |
| 17 | * const cancelPing = effect([$enabled, $interval], (enabled, interval) => { |
| 18 | * if (!enabled) return |
| 19 | * const intervalId = setInterval(() => { |
| 20 | * sendPing() |
| 21 | * }, interval) |
| 22 | * return () => { |
| 23 | * clearInterval(intervalId) |
| 24 | * } |
| 25 | * }) |
| 26 | * ``` |
| 27 | */ |
| 28 | <OriginStores extends AnyStore[]>( |
| 29 | stores: [...OriginStores], |
| 30 | cb: (...values: StoreValues<OriginStores>) => (() => void) | void |
nothing calls this directly
no outgoing calls
no test coverage detected