store.d.ts 609 B

1234567891011121314151617181920212223242526272829
  1. interface Options {
  2. immutable: boolean;
  3. }
  4. interface Cancellable {
  5. cancel: () => void;
  6. }
  7. interface Tuple<T extends any, L extends number> extends Array<T> {
  8. 0: T;
  9. length: L;
  10. }
  11. type State = Record<string, any>;
  12. export declare class Store {
  13. constructor(state: State, options?: Options);
  14. public compute<L extends number>(
  15. key: string,
  16. dependencies: Tuple<string, L>,
  17. fn: (...dependencies: Tuple<any, L>) => any,
  18. ): void;
  19. public fire(name: string, data?: any): void;
  20. public get(): State;
  21. public on(name: string, callback: (data: any) => void): Cancellable;
  22. public set(state: State): void;
  23. }