import { Watcher } from "./lib.js"; export type Disposer = () => void; export interface Unit { watch(watcher: (params: Params, ext: Ext) => void): Disposer; } export interface Call { (params: Input | Promise): Output; } export interface Action extends Call< Input, void > { watch( this: Action>, watcher: (params: Param) => void, ): Disposer; watch(watcher: (params: Output) => void): Disposer; map( this: Action>, map: (params: Param) => Promise | Mapped, ): Action; map( fn: (params: Output) => Promise | Mapped, ): Action; filter( this: Action>, fn: (params: Param) => Promise | boolean, ): Action; filter( fn: (params: Output) => Promise | boolean, ): Action; task( this: Action>, fn: (params: Param) => Promise | Result, ): Task; task( fn: (input: Output) => Promise | Result, ): Task; } export interface Task extends Call>, Unit { done: Unit; fail: Unit; end: Unit; } export interface StorePart extends Unit { get(): State; map(mapper: (state: State) => Selected): StorePart; subscribe(watcher: Watcher): Disposer; off: Disposer; } export interface Store extends StorePart { on(unit: Unit): Store; on( unit: Unit, fn: (state: State, params: Params, ext: Ext) => State, ): Store; set(state: State): void; off(unit?: Unit): Store; }