import { Slice } from '../slice'; /** * Derives a snapshot from a mutable source that is assumed local to the * component that is using this hook. The snapshot is considered atomic. * "getSnapshot" should be static (dynamic values won't be taken into account). * * @param getSnapshot - function that returns an immutable atomic snapshot of the source * @param slice - the slice of state represented by the snapshot * @returns the snapshot */ export declare function useSnapshot(getSnapshot: (currentSnapshot: Snapshot | null) => Snapshot, slice: Slice): Snapshot; /** * Generates a source, and allows to use it safely inside any component. * * @param init - function that generates the source, it can optionally returns also a "destroy" function * @param getSnapshot - function that returns an immutable atomic snapshot of the source * @param contract - function to register a callback that is called whenever the source changes * @returns the snapshot and a function to lazily initialize the source */ export declare function useSource(init: () => [source: Source, destroy?: (source: Source) => void], contract: (source: Source, onChange: () => void) => void | (() => void), getSnapshot: (source: Source | null, currentSnapshot: Snapshot | null) => Snapshot): readonly [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 and the contract should be side-effect free. * After the contract is signed, the source should be garbage collectable. * * @param init - function that generates the source * @param getSnapshot - function that returns an immutable atomic snapshot of the source * @param contract - function to register a callback that is called whenever the source changes * @returns the snapshot and the source */ export declare function usePureSource(init: () => Source, contract: (source: Source, onChange: () => void) => void, getSnapshot: (source: Source, currentSnapshot: Snapshot | null) => Snapshot): readonly [Snapshot, Source];