/** @module hareactive/stream */ import { MapFunction, SubscribeFunction, ScanFunction, FilterFunction, Consumer } from "./frp-common"; import { Behavior } from "./Behavior"; /** * A stream is a list of occurences over time. Each occurence happens * at a discrete point in time and has an associated value. * Semantically it is a list `type Stream = [Time, A]`. */ export declare abstract class Stream { eventListeners: any[]; data: any; push: (a: any, s: Stream, b: any) => void; constructor(data: any, push: any); publish(a: A): void; subscribe(fn: (a: A) => void): void; map(fn: MapFunction): Stream; filter(fn: FilterFunction): Stream; scanS(fn: ScanFunction, startingValue: B): Behavior>; scan(fn: ScanFunction, init: B): Behavior>; unlisten(listener: Consumer): void; } /** * @param fn A predicate function that returns a boolean for `A`. * @param stream The stream to filter. * @returns Stream that only contains the occurences from `stream` * for which `fn` returns true. */ export declare function filter(fn: (a: A) => boolean, stream: Stream): Stream; /** * The returned initially has the initial value, on each * occurence in `source` the function is applied to the current value * of the behaviour and the value of the occurence, the returned value * becomes the next value of the behavior. */ export declare function scanS(fn: ScanFunction, startingValue: B, stream: Stream): Behavior>; /** * Takes a stream valued behavior and returns at stream that emits * values from the current stream at the behavior. */ /** * @returns A stream that never has any occurrences. */ export declare function empty(): Stream; export declare function subscribe(fn: SubscribeFunction, stream: Stream): void; export declare function publish(a: A, stream: Stream): void; export declare function map(fn: MapFunction, stream: Stream): Stream; export declare function isStream(obj: any): boolean;