S.d.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. export interface S {
  2. root<T>(fn: (dispose: () => void) => T): T;
  3. <T>(fn: () => T): () => T;
  4. <T>(fn: (v: T) => T, seed: T): () => T;
  5. on<T>(ev: () => any, fn: () => T): () => T;
  6. on<T>(ev: () => any, fn: (v: T) => T, seed: T, onchanges?: boolean): () => T;
  7. effect<T>(fn: () => T): void;
  8. effect<T>(fn: (v: T) => T, seed: T): void;
  9. data<T>(value: T): DataSignal<T>;
  10. value<T>(value: T, eq?: (a: T, b: T) => boolean): DataSignal<T>;
  11. freeze<T>(fn: () => T): T;
  12. sample<T>(fn: () => T): T;
  13. cleanup(fn: (final: boolean) => any): void;
  14. isFrozen(): boolean;
  15. isListening(): boolean;
  16. makeDataNode<T>(value: T): IDataNode<T>;
  17. makeComputationNode<T>(fn: () => T): IComputationNode<T>;
  18. makeComputationNode<T>(fn: (val: T) => T, seed: T): IComputationNode<T>;
  19. }
  20. export interface DataSignal<T> {
  21. (): T;
  22. (val: T): T;
  23. }
  24. declare var S: S;
  25. export default S;
  26. export interface IDataNode<T> {
  27. clock(): IClock;
  28. current(): T;
  29. next(value: T): T;
  30. }
  31. export interface IComputationNode<T> {
  32. clock(): IClock;
  33. current(): T;
  34. }
  35. export interface IClock {
  36. time(): number;
  37. }