import { type DependencyList } from 'react'; /** * Generates a source, and allows to use it safely inside any component. The * source is re-created every time a dependency changes. * * @param init - function that generates the source, it can optionally returns also a "destroy" function * @param deps - dependency list that defines the source lifecycle * @returns an hook to derive snapshots and a function to lazily initialize the source */ export declare function useSource(init: () => [source: Source, destroy?: (source: Source) => void], deps?: DependencyList): readonly [(getSnapshot: (source: Source | null, currentSnapshot: Snapshot | null) => Snapshot, ...rest: [subscribe: (source: Source, onChange: () => void) => () => void] | [(source: Source, onChange: () => void) => () => void, (DependencyList | undefined)?] | [DependencyList | undefined, (source: Source, onChange: () => void) => () => void] | [DependencyList | undefined, (source: Source, onChange: () => void) => () => void, (DependencyList | undefined)?]) => Snapshot, () => Source]; /** * Generates a pure source, and allows to use it safely inside any component. * The source is re-created every time a dependency changes. * The source generation should be side-effect free. * * @param init - function that generates the source * @param deps - dependency list that define the source lifecycle * @returns an hook to derive snapshots and the source */ export declare function usePureSource(init: () => Source, deps?: DependencyList): readonly [(getSnapshot: (source: Source, currentSnapshot: Snapshot | null) => Snapshot, ...rest: [subscribe: (source: Source, onChange: () => void) => () => void] | [(source: Source, onChange: () => void) => () => void, (DependencyList | undefined)?] | [DependencyList | undefined, (source: Source, onChange: () => void) => () => void] | [DependencyList | undefined, (source: Source, onChange: () => void) => () => void, (DependencyList | undefined)?]) => Snapshot, Source];