/opt/canhelp/node_modules/nanostores/effect
Edit: /opt/canhelp/node_modules/nanostores/effect/index.d.ts (943B)
import type { StoreValues } from '../computed/index.d.ts'
import type { AnyStore, Store, StoreValue } from '../index.js'
interface Effect {
(
stores: OriginStore,
cb: (value: StoreValue) => (() => void) | void
): () => void
/**
* Subscribe for multiple stores. Also you can define cleanup function
* to call on stores changes.
*
* ```js
* const $enabled = atom(true)
* const $interval = atom(1000)
*
* const cancelPing = effect([$enabled, $interval], (enabled, interval) => {
* if (!enabled) return
* const intervalId = setInterval(() => {
* sendPing()
* }, interval)
* return () => {
* clearInterval(intervalId)
* }
* })
* ```
*/
(
stores: [...OriginStores],
cb: (...values: StoreValues) => (() => void) | void
): () => void
}
export const effect: Effect