import type Ticker from '../Ticker' import type {$IntentionalAny, VoidFn} from '../types' import type Tappable from '../utils/Tappable' type IDependent = (msgComingFrom: IDerivation<$IntentionalAny>) => void export interface IDerivation { isDerivation: true isHot: boolean changes(ticker: Ticker): Tappable changesWithoutValues(): Tappable keepHot(): VoidFn tapImmediate(ticker: Ticker, fn: (cb: V) => void): VoidFn addDependent(d: IDependent): void removeDependent(d: IDependent): void getValue(): V map(fn: (v: V) => T): IDerivation flatMap( fn: (v: V) => R, ): IDerivation ? T : R> } export function isDerivation(d: any): d is IDerivation { return d && d.isDerivation && d.isDerivation === true }