import { Monad } from "jabz/monad"; import { Consumer, Observer } from "./frp-common"; import { Behavior } from "./behavior"; /** * A future is a thing that occurs at some point in time with a value. * It can be understood as a pair consisting of the time the future * occurs and its associated value. It is quite like a JavaScript * promise. */ export declare abstract class Future implements Monad, Consumer { occured: boolean; value: A; protected listeners: Consumer[]; constructor(); listen(o: Consumer): void; subscribe(f: (a: A) => void): void; abstract push(val: any): void; resolve(val: A): void; map(f: (a: A) => B): Future; mapTo(b: B): Future; static of(b: B): Future; of(b: B): Future; ap: (f: Future<(a: A) => B>) => Future; lift(f: (t: T1) => R, m: Future): Future; lift(f: (t: T1, u: T2) => R, m1: Future, m2: Future): Future; lift(f: (t1: T1, t2: T2, t3: T3) => R, m1: Future, m2: Future, m3: Future): Future; static multi: false; multi: boolean; chain(f: (a: A) => Future): Future; flatten: () => Future; } export declare function sinkFuture(): Future; export declare function fromPromise(p: Promise): Future; /** * Create a future from a pushing behavior. The future occurs when the * behavior pushes its next value. Constructing a BehaviorFuture is * impure and should not be done direcly. * @private */ export declare class BehaviorFuture extends Future implements Observer { private b; constructor(b: Behavior); endPulling(): void; beginPulling(): void; push(a: A): void; }