import { Lambda1, Lambda2, Lambda3, Lambda4, Lambda5, Lambda6 } from "./Lambda"; import { Vertex } from "./Vertex"; import { Cell } from "./Cell"; import { Listener } from "./Listener"; import { Tuple2 } from "./Tuple2"; import { Lazy } from "./Lazy"; export declare class Stream { constructor(vertex?: Vertex); getVertex__(): Vertex; protected vertex: Vertex; protected listeners: Array>; protected firings: A[]; /** * Transform the stream's event values according to the supplied function, so the returned * Stream's event values reflect the value of the function applied to the input * Stream's event values. * @param f Function to apply to convert the values. It may construct FRP logic or use * {@link Cell#sample()} in which case it is equivalent to {@link Stream#snapshot(Cell)}ing the * cell. Apart from this the function must be referentially transparent. */ map(f: ((a: A) => B) | Lambda1): Stream; /** * Transform the stream's event values into the specified constant value. * @param b Constant value. */ mapTo(b: B): Stream; /** * Variant of {@link Stream#merge(Stream, Lambda2)} that merges two streams and will drop an event * in the simultaneous case. *

* In the case where two events are simultaneous (i.e. both * within the same transaction), the event from this will take precedence, and * the event from s will be dropped. * If you want to specify your own combining function, use {@link Stream#merge(Stream, Lambda2)}. * s1.orElse(s2) is equivalent to s1.merge(s2, (l, r) -> l). *

* The name orElse() is used instead of merge() to make it really clear that care should * be taken, because events can be dropped. */ orElse(s: Stream): Stream; /** * Merge two streams of the same type into one, so that events on either input appear * on the returned stream. *

* If the events are simultaneous (that is, one event from this and one from s * occurring in the same transaction), combine them into one using the specified combining function * so that the returned stream is guaranteed only ever to have one event per transaction. * The event from this will appear at the left input of the combining function, and * the event from s will appear at the right. * @param f Function to combine the values. It may construct FRP logic or use * {@link Cell#sample()}. Apart from this the function must be referentially transparent. */ merge(s: Stream, f: ((left: A, right: A) => A) | Lambda2): Stream; /** * Return a stream that only outputs events for which the predicate returns true. */ filter(f: ((a: A) => boolean) | Lambda1): Stream; /** * Return a stream that only outputs events that have present * values, discarding null values. */ filterNotNull(): Stream; /** * Return a stream that only outputs events from the input stream * when the specified cell's value is true. */ gate(c: Cell): Stream; /** * Variant of {@link snapshot(Cell, Lambda2)} that captures the cell's value * at the time of the event firing, ignoring the stream's value. */ snapshot1(c: Cell): Stream; /** * Return a stream whose events are the result of the combination using the specified * function of the input stream's event value and the value of the cell at that time. *

* There is an implicit delay: State updates caused by event firings being held with * {@link Stream#hold(Object)} don't become visible as the cell's current value until * the following transaction. To put this another way, {@link Stream#snapshot(Cell, Lambda2)} * always sees the value of a cell as it was before any state changes from the current * transaction. */ snapshot(b: Cell, f_: ((a: A, b: B) => C) | Lambda2): Stream; /** * Return a stream whose events are the result of the combination using the specified * function of the input stream's event value and the value of the cells at that time. *

* There is an implicit delay: State updates caused by event firings being held with * {@link Stream#hold(Object)} don't become visible as the cell's current value until * the following transaction. To put this another way, snapshot() * always sees the value of a cell as it was before any state changes from the current * transaction. */ snapshot3(b: Cell, c: Cell, f_: ((a: A, b: B, c: C) => D) | Lambda3): Stream; /** * Return a stream whose events are the result of the combination using the specified * function of the input stream's event value and the value of the cells at that time. *

* There is an implicit delay: State updates caused by event firings being held with * {@link Stream#hold(Object)} don't become visible as the cell's current value until * the following transaction. To put this another way, snapshot() * always sees the value of a cell as it was before any state changes from the current * transaction. */ snapshot4(b: Cell, c: Cell, d: Cell, f_: ((a: A, b: B, c: C, d: D) => E) | Lambda4): Stream; /** * Return a stream whose events are the result of the combination using the specified * function of the input stream's event value and the value of the cells at that time. *

* There is an implicit delay: State updates caused by event firings being held with * {@link Stream#hold(Object)} don't become visible as the cell's current value until * the following transaction. To put this another way, snapshot() * always sees the value of a cell as it was before any state changes from the current * transaction. */ snapshot5(b: Cell, c: Cell, d: Cell, e: Cell, f_: ((a: A, b: B, c: C, d: D, e: E) => F) | Lambda5): Stream; /** * Return a stream whose events are the result of the combination using the specified * function of the input stream's event value and the value of the cells at that time. *

* There is an implicit delay: State updates caused by event firings being held with * {@link Stream#hold(Object)} don't become visible as the cell's current value until * the following transaction. To put this another way, snapshot() * always sees the value of a cell as it was before any state changes from the current * transaction. */ snapshot6(b: Cell, c: Cell, d: Cell, e: Cell, f: Cell, f_: ((a: A, b: B, c: C, d: D, e: E, f: F) => G) | Lambda6): Stream; /** * Create a {@link Cell} with the specified initial value, that is updated * by this stream's event values. *

* There is an implicit delay: State updates caused by event firings don't become * visible as the cell's current value as viewed by {@link Stream#snapshot(Cell, Lambda2)} * until the following transaction. To put this another way, * {@link Stream#snapshot(Cell, Lambda2)} always sees the value of a cell as it was before * any state changes from the current transaction. */ hold(initValue: A): Cell; /** * A variant of {@link hold(Object)} with an initial value captured by {@link Cell#sampleLazy()}. */ holdLazy(initValue: Lazy): Cell; /** * Transform an event with a generalized state loop (a Mealy machine). The function * is passed the input and the old state and returns the new state and output value. * @param f Function to apply to update the state. It may construct FRP logic or use * {@link Cell#sample()} in which case it is equivalent to {@link Stream#snapshot(Cell)}ing the * cell. Apart from this the function must be referentially transparent. */ collect(initState: S, f: ((a: A, s: S) => Tuple2) | Lambda2>): Stream; /** * A variant of {@link collect(Object, Lambda2)} that takes an initial state returned by * {@link Cell#sampleLazy()}. */ collectLazy(initState: Lazy, f: ((a: A, s: S) => Tuple2) | Lambda2>): Stream; /** * Accumulate on input event, outputting the new state each time. * @param f Function to apply to update the state. It may construct FRP logic or use * {@link Cell#sample()} in which case it is equivalent to {@link Stream#snapshot(Cell)}ing the * cell. Apart from this the function must be referentially transparent. */ accum(initState: S, f: ((a: A, s: S) => S) | Lambda2): Cell; /** * A variant of {@link accum(Object, Lambda2)} that takes an initial state returned by * {@link Cell#sampleLazy()}. */ accumLazy(initState: Lazy, f: ((a: A, s: S) => S) | Lambda2): Cell; /** * Return a stream that outputs only one value: the next event of the * input stream, starting from the transaction in which once() was invoked. */ once(): Stream; listen(h: (a: A) => void): () => void; listen_(target: Vertex, h: (a: A) => void, suppressEarlierFirings: boolean): () => void; /** * Fantasy-land Algebraic Data Type Compatability. * Stream satisfies the Functor and Monoid Categories (and hence Semigroup) * @see {@link https://github.com/fantasyland/fantasy-land} for more info */ 'fantasy-land/map'(f: ((a: A) => B)): Stream; 'fantasy-land/concat'(a: Stream): Stream; 'fantasy-land/empty'(): Stream; } export declare class StreamWithSend extends Stream { constructor(vertex?: Vertex); setVertex__(vertex: Vertex): void; send_(a: A): void; } /** * A forward reference for a {@link Stream} equivalent to the Stream that is referenced. */ export declare class StreamLoop extends StreamWithSend { assigned__: boolean; constructor(); /** * Resolve the loop to specify what the StreamLoop was a forward reference to. It * must be invoked inside the same transaction as the place where the StreamLoop is used. * This requires you to create an explicit transaction with {@link Transaction#run(Lambda0)} * or {@link Transaction#runVoid(Runnable)}. */ loop(sa_out: Stream): void; }