from
Edit this pageA helper to make it easier to interop with external producers like RxJS observables or with Svelte Stores. This basically turns any subscribable (object with a subscribe method) into a Signal and manages subscription and disposal.
It can also take a custom producer function where the function is passed a setter function that returns an unsubscribe function:
Arguments
Name | Type | Description |
---|---|---|
producer | ((setter: (v: T) => T) => () => void) | { subscribe: (fn: (v: T) => void) => (() => void) | { unsubscribe: () => void }; } | The producer function or subscribable object |