/** @module hareactive/stream */ import { Reactive } 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 extends Reactive { constructor(); abstract push(a: any): void; map(fn: (a: A) => B): Stream; mapTo(val: B): Stream; merge(otherStream: Stream): Stream<(A | B)>; filter(fn: (a: A) => boolean): Stream; scanS(fn: (a: A, b: B) => B, startingValue: B): Behavior>; scan(fn: (a: A, b: B) => B, init: B): Behavior>; } /** @private */ export declare class SinkStream extends Stream { push(a: A): void; } export declare function map(fn: (a: A) => B, stream: Stream): Stream; /** * @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: (a: A, b: B) => B, startingValue: B, stream: Stream): Behavior>; export declare function snapshot(behavior: Behavior, stream: Stream): Stream; export declare function snapshotWith(fn: (a: A, b: B) => C, behavior: Behavior, stream: Stream): Stream; /** * Takes a stream valued behavior and returns at stream that emits * values from the current stream at the behavior. I.e. the returned * stream always "switches" to the current stream at the behavior. */ export declare function switchStream(b: Behavior>): Stream; export declare function changes(b: Behavior): Stream; export declare function mergeList(ss: Stream[]): Stream; /** * @returns A stream that never has any occurrences. */ export declare function empty(): Stream; export declare function subscribe(fn: (a: A) => void, stream: Stream): void; export declare function publish(a: A, stream: Stream): void; export declare function merge(a: Stream, b: Stream): Stream<(A | B)>; export declare function isStream(obj: any): boolean;