use-mutable-source
Version:
Minimal and elegant way to integrate any library with React
20 lines (19 loc) • 566 B
TypeScript
/**
* This class represents a Slice of a state that can receives and notify updates.
* The Slice has a version that is modified each time an updates is received.
*/
export declare class Slice {
version: number;
private listeners;
/**
* Updates the Slice version and notify all listeners.
*/
update: () => void;
/**
* Adds a listener for updates.
*
* @param listener - the listener
* @returns a function to remove the listener
*/
subscribe: (listener: () => void) => () => undefined;
}