UNPKG

26.4 kBTypeScriptView Raw
1declare const NO: {};
2export interface InternalListener<T> {
3 _n: (v: T) => void;
4 _e: (err: any) => void;
5 _c: () => void;
6}
7declare const NO_IL: InternalListener<any>;
8export interface InternalProducer<T> {
9 _start: (listener: InternalListener<T>) => void;
10 _stop: () => void;
11}
12export interface OutSender<T> {
13 out: Stream<T>;
14}
15export interface Operator<T, R> extends InternalProducer<R>, InternalListener<T>, OutSender<R> {
16 type: string;
17 ins: Stream<T>;
18 _start: (out: Stream<R>) => void;
19}
20export interface Aggregator<T, U> extends InternalProducer<U>, OutSender<U> {
21 type: string;
22 insArr: Array<Stream<T>>;
23 _start: (out: Stream<U>) => void;
24}
25export interface Producer<T> {
26 start: (listener: Listener<T>) => void;
27 stop: () => void;
28}
29export interface Listener<T> {
30 next: (x: T) => void;
31 error: (err: any) => void;
32 complete: () => void;
33}
34export interface Subscription {
35 unsubscribe(): void;
36}
37export interface Observable<T> {
38 subscribe(listener: Listener<T>): Subscription;
39}
40export interface MergeSignature {
41 (): Stream<any>;
42 <T1>(s1: Stream<T1>): Stream<T1>;
43 <T1, T2>(s1: Stream<T1>, s2: Stream<T2>): Stream<T1 | T2>;
44 <T1, T2, T3>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>): Stream<T1 | T2 | T3>;
45 <T1, T2, T3, T4>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>): Stream<T1 | T2 | T3 | T4>;
46 <T1, T2, T3, T4, T5>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>): Stream<T1 | T2 | T3 | T4 | T5>;
47 <T1, T2, T3, T4, T5, T6>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>): Stream<T1 | T2 | T3 | T4 | T5 | T6>;
48 <T1, T2, T3, T4, T5, T6, T7>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>): Stream<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
49 <T1, T2, T3, T4, T5, T6, T7, T8>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>, s8: Stream<T8>): Stream<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
50 <T1, T2, T3, T4, T5, T6, T7, T8, T9>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>, s8: Stream<T8>, s9: Stream<T9>): Stream<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
51 <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>, s8: Stream<T8>, s9: Stream<T9>, s10: Stream<T10>): Stream<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
52 <T>(...stream: Array<Stream<T>>): Stream<T>;
53}
54export interface CombineSignature {
55 (): Stream<Array<any>>;
56 <T1>(s1: Stream<T1>): Stream<[T1]>;
57 <T1, T2>(s1: Stream<T1>, s2: Stream<T2>): Stream<[T1, T2]>;
58 <T1, T2, T3>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>): Stream<[T1, T2, T3]>;
59 <T1, T2, T3, T4>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>): Stream<[T1, T2, T3, T4]>;
60 <T1, T2, T3, T4, T5>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>): Stream<[T1, T2, T3, T4, T5]>;
61 <T1, T2, T3, T4, T5, T6>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>): Stream<[T1, T2, T3, T4, T5, T6]>;
62 <T1, T2, T3, T4, T5, T6, T7>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>): Stream<[T1, T2, T3, T4, T5, T6, T7]>;
63 <T1, T2, T3, T4, T5, T6, T7, T8>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>, s8: Stream<T8>): Stream<[T1, T2, T3, T4, T5, T6, T7, T8]>;
64 <T1, T2, T3, T4, T5, T6, T7, T8, T9>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>, s8: Stream<T8>, s9: Stream<T9>): Stream<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
65 <T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(s1: Stream<T1>, s2: Stream<T2>, s3: Stream<T3>, s4: Stream<T4>, s5: Stream<T5>, s6: Stream<T6>, s7: Stream<T7>, s8: Stream<T8>, s9: Stream<T9>, s10: Stream<T10>): Stream<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
66 (...stream: Array<Stream<any>>): Stream<Array<any>>;
67}
68export declare class Stream<T> implements InternalListener<T> {
69 _prod: InternalProducer<T>;
70 protected _ils: Array<InternalListener<T>>;
71 protected _stopID: any;
72 protected _dl: InternalListener<T>;
73 protected _d: boolean;
74 protected _target: Stream<T>;
75 protected _err: any;
76 constructor(producer?: InternalProducer<T>);
77 _n(t: T): void;
78 _e(err: any): void;
79 _c(): void;
80 _x(): void;
81 _stopNow(): void;
82 _add(il: InternalListener<T>): void;
83 _remove(il: InternalListener<T>): void;
84 _pruneCycles(): void;
85 _hasNoSinks(x: InternalListener<any>, trace: Array<any>): boolean;
86 private ctor();
87 /**
88 * Adds a Listener to the Stream.
89 *
90 * @param {Listener} listener
91 */
92 addListener(listener: Partial<Listener<T>>): void;
93 /**
94 * Removes a Listener from the Stream, assuming the Listener was added to it.
95 *
96 * @param {Listener<T>} listener
97 */
98 removeListener(listener: Partial<Listener<T>>): void;
99 /**
100 * Adds a Listener to the Stream returning a Subscription to remove that
101 * listener.
102 *
103 * @param {Listener} listener
104 * @returns {Subscription}
105 */
106 subscribe(listener: Listener<T>): Subscription;
107 /**
108 * Creates a new Stream given a Producer.
109 *
110 * @factory true
111 * @param {Producer} producer An optional Producer that dictates how to
112 * start, generate events, and stop the Stream.
113 * @return {Stream}
114 */
115 static create<T>(producer?: Producer<T>): Stream<T>;
116 /**
117 * Creates a new MemoryStream given a Producer.
118 *
119 * @factory true
120 * @param {Producer} producer An optional Producer that dictates how to
121 * start, generate events, and stop the Stream.
122 * @return {MemoryStream}
123 */
124 static createWithMemory<T>(producer?: Producer<T>): MemoryStream<T>;
125 /**
126 * Creates a Stream that does nothing when started. It never emits any event.
127 *
128 * Marble diagram:
129 *
130 * ```text
131 * never
132 * -----------------------
133 * ```
134 *
135 * @factory true
136 * @return {Stream}
137 */
138 static never(): Stream<any>;
139 /**
140 * Creates a Stream that immediately emits the "complete" notification when
141 * started, and that's it.
142 *
143 * Marble diagram:
144 *
145 * ```text
146 * empty
147 * -|
148 * ```
149 *
150 * @factory true
151 * @return {Stream}
152 */
153 static empty(): Stream<any>;
154 /**
155 * Creates a Stream that immediately emits an "error" notification with the
156 * value you passed as the `error` argument when the stream starts, and that's
157 * it.
158 *
159 * Marble diagram:
160 *
161 * ```text
162 * throw(X)
163 * -X
164 * ```
165 *
166 * @factory true
167 * @param error The error event to emit on the created stream.
168 * @return {Stream}
169 */
170 static throw(error: any): Stream<any>;
171 /**
172 * Creates a stream from an Array, Promise, or an Observable.
173 *
174 * @factory true
175 * @param {Array|PromiseLike|Observable} input The input to make a stream from.
176 * @return {Stream}
177 */
178 static from<T>(input: PromiseLike<T> | Stream<T> | Array<T> | Observable<T>): Stream<T>;
179 /**
180 * Creates a Stream that immediately emits the arguments that you give to
181 * *of*, then completes.
182 *
183 * Marble diagram:
184 *
185 * ```text
186 * of(1,2,3)
187 * 123|
188 * ```
189 *
190 * @factory true
191 * @param a The first value you want to emit as an event on the stream.
192 * @param b The second value you want to emit as an event on the stream. One
193 * or more of these values may be given as arguments.
194 * @return {Stream}
195 */
196 static of<T>(...items: Array<T>): Stream<T>;
197 /**
198 * Converts an array to a stream. The returned stream will emit synchronously
199 * all the items in the array, and then complete.
200 *
201 * Marble diagram:
202 *
203 * ```text
204 * fromArray([1,2,3])
205 * 123|
206 * ```
207 *
208 * @factory true
209 * @param {Array} array The array to be converted as a stream.
210 * @return {Stream}
211 */
212 static fromArray<T>(array: Array<T>): Stream<T>;
213 /**
214 * Converts a promise to a stream. The returned stream will emit the resolved
215 * value of the promise, and then complete. However, if the promise is
216 * rejected, the stream will emit the corresponding error.
217 *
218 * Marble diagram:
219 *
220 * ```text
221 * fromPromise( ----42 )
222 * -----------------42|
223 * ```
224 *
225 * @factory true
226 * @param {PromiseLike} promise The promise to be converted as a stream.
227 * @return {Stream}
228 */
229 static fromPromise<T>(promise: PromiseLike<T>): Stream<T>;
230 /**
231 * Converts an Observable into a Stream.
232 *
233 * @factory true
234 * @param {any} observable The observable to be converted as a stream.
235 * @return {Stream}
236 */
237 static fromObservable<T>(obs: {
238 subscribe: any;
239 }): Stream<T>;
240 /**
241 * Creates a stream that periodically emits incremental numbers, every
242 * `period` milliseconds.
243 *
244 * Marble diagram:
245 *
246 * ```text
247 * periodic(1000)
248 * ---0---1---2---3---4---...
249 * ```
250 *
251 * @factory true
252 * @param {number} period The interval in milliseconds to use as a rate of
253 * emission.
254 * @return {Stream}
255 */
256 static periodic(period: number): Stream<number>;
257 /**
258 * Blends multiple streams together, emitting events from all of them
259 * concurrently.
260 *
261 * *merge* takes multiple streams as arguments, and creates a stream that
262 * behaves like each of the argument streams, in parallel.
263 *
264 * Marble diagram:
265 *
266 * ```text
267 * --1----2-----3--------4---
268 * ----a-----b----c---d------
269 * merge
270 * --1-a--2--b--3-c---d--4---
271 * ```
272 *
273 * @factory true
274 * @param {Stream} stream1 A stream to merge together with other streams.
275 * @param {Stream} stream2 A stream to merge together with other streams. Two
276 * or more streams may be given as arguments.
277 * @return {Stream}
278 */
279 static merge: MergeSignature;
280 /**
281 * Combines multiple input streams together to return a stream whose events
282 * are arrays that collect the latest events from each input stream.
283 *
284 * *combine* internally remembers the most recent event from each of the input
285 * streams. When any of the input streams emits an event, that event together
286 * with all the other saved events are combined into an array. That array will
287 * be emitted on the output stream. It's essentially a way of joining together
288 * the events from multiple streams.
289 *
290 * Marble diagram:
291 *
292 * ```text
293 * --1----2-----3--------4---
294 * ----a-----b-----c--d------
295 * combine
296 * ----1a-2a-2b-3b-3c-3d-4d--
297 * ```
298 *
299 * Note: to minimize garbage collection, *combine* uses the same array
300 * instance for each emission. If you need to compare emissions over time,
301 * cache the values with `map` first:
302 *
303 * ```js
304 * import pairwise from 'xstream/extra/pairwise'
305 *
306 * const stream1 = xs.of(1);
307 * const stream2 = xs.of(2);
308 *
309 * xs.combine(stream1, stream2).map(
310 * combinedEmissions => ([ ...combinedEmissions ])
311 * ).compose(pairwise)
312 * ```
313 *
314 * @factory true
315 * @param {Stream} stream1 A stream to combine together with other streams.
316 * @param {Stream} stream2 A stream to combine together with other streams.
317 * Multiple streams, not just two, may be given as arguments.
318 * @return {Stream}
319 */
320 static combine: CombineSignature;
321 protected _map<U>(project: (t: T) => U): Stream<U> | MemoryStream<U>;
322 /**
323 * Transforms each event from the input Stream through a `project` function,
324 * to get a Stream that emits those transformed events.
325 *
326 * Marble diagram:
327 *
328 * ```text
329 * --1---3--5-----7------
330 * map(i => i * 10)
331 * --10--30-50----70-----
332 * ```
333 *
334 * @param {Function} project A function of type `(t: T) => U` that takes event
335 * `t` of type `T` from the input Stream and produces an event of type `U`, to
336 * be emitted on the output Stream.
337 * @return {Stream}
338 */
339 map<U>(project: (t: T) => U): Stream<U>;
340 /**
341 * It's like `map`, but transforms each input event to always the same
342 * constant value on the output Stream.
343 *
344 * Marble diagram:
345 *
346 * ```text
347 * --1---3--5-----7-----
348 * mapTo(10)
349 * --10--10-10----10----
350 * ```
351 *
352 * @param projectedValue A value to emit on the output Stream whenever the
353 * input Stream emits any value.
354 * @return {Stream}
355 */
356 mapTo<U>(projectedValue: U): Stream<U>;
357 filter<S extends T>(passes: (t: T) => t is S): Stream<S>;
358 filter(passes: (t: T) => boolean): Stream<T>;
359 /**
360 * Lets the first `amount` many events from the input stream pass to the
361 * output stream, then makes the output stream complete.
362 *
363 * Marble diagram:
364 *
365 * ```text
366 * --a---b--c----d---e--
367 * take(3)
368 * --a---b--c|
369 * ```
370 *
371 * @param {number} amount How many events to allow from the input stream
372 * before completing the output stream.
373 * @return {Stream}
374 */
375 take(amount: number): Stream<T>;
376 /**
377 * Ignores the first `amount` many events from the input stream, and then
378 * after that starts forwarding events from the input stream to the output
379 * stream.
380 *
381 * Marble diagram:
382 *
383 * ```text
384 * --a---b--c----d---e--
385 * drop(3)
386 * --------------d---e--
387 * ```
388 *
389 * @param {number} amount How many events to ignore from the input stream
390 * before forwarding all events from the input stream to the output stream.
391 * @return {Stream}
392 */
393 drop(amount: number): Stream<T>;
394 /**
395 * When the input stream completes, the output stream will emit the last event
396 * emitted by the input stream, and then will also complete.
397 *
398 * Marble diagram:
399 *
400 * ```text
401 * --a---b--c--d----|
402 * last()
403 * -----------------d|
404 * ```
405 *
406 * @return {Stream}
407 */
408 last(): Stream<T>;
409 /**
410 * Prepends the given `initial` value to the sequence of events emitted by the
411 * input stream. The returned stream is a MemoryStream, which means it is
412 * already `remember()`'d.
413 *
414 * Marble diagram:
415 *
416 * ```text
417 * ---1---2-----3---
418 * startWith(0)
419 * 0--1---2-----3---
420 * ```
421 *
422 * @param initial The value or event to prepend.
423 * @return {MemoryStream}
424 */
425 startWith(initial: T): MemoryStream<T>;
426 /**
427 * Uses another stream to determine when to complete the current stream.
428 *
429 * When the given `other` stream emits an event or completes, the output
430 * stream will complete. Before that happens, the output stream will behaves
431 * like the input stream.
432 *
433 * Marble diagram:
434 *
435 * ```text
436 * ---1---2-----3--4----5----6---
437 * endWhen( --------a--b--| )
438 * ---1---2-----3--4--|
439 * ```
440 *
441 * @param other Some other stream that is used to know when should the output
442 * stream of this operator complete.
443 * @return {Stream}
444 */
445 endWhen(other: Stream<any>): Stream<T>;
446 /**
447 * "Folds" the stream onto itself.
448 *
449 * Combines events from the past throughout
450 * the entire execution of the input stream, allowing you to accumulate them
451 * together. It's essentially like `Array.prototype.reduce`. The returned
452 * stream is a MemoryStream, which means it is already `remember()`'d.
453 *
454 * The output stream starts by emitting the `seed` which you give as argument.
455 * Then, when an event happens on the input stream, it is combined with that
456 * seed value through the `accumulate` function, and the output value is
457 * emitted on the output stream. `fold` remembers that output value as `acc`
458 * ("accumulator"), and then when a new input event `t` happens, `acc` will be
459 * combined with that to produce the new `acc` and so forth.
460 *
461 * Marble diagram:
462 *
463 * ```text
464 * ------1-----1--2----1----1------
465 * fold((acc, x) => acc + x, 3)
466 * 3-----4-----5--7----8----9------
467 * ```
468 *
469 * @param {Function} accumulate A function of type `(acc: R, t: T) => R` that
470 * takes the previous accumulated value `acc` and the incoming event from the
471 * input stream and produces the new accumulated value.
472 * @param seed The initial accumulated value, of type `R`.
473 * @return {MemoryStream}
474 */
475 fold<R>(accumulate: (acc: R, t: T) => R, seed: R): MemoryStream<R>;
476 /**
477 * Replaces an error with another stream.
478 *
479 * When (and if) an error happens on the input stream, instead of forwarding
480 * that error to the output stream, *replaceError* will call the `replace`
481 * function which returns the stream that the output stream will replicate.
482 * And, in case that new stream also emits an error, `replace` will be called
483 * again to get another stream to start replicating.
484 *
485 * Marble diagram:
486 *
487 * ```text
488 * --1---2-----3--4-----X
489 * replaceError( () => --10--| )
490 * --1---2-----3--4--------10--|
491 * ```
492 *
493 * @param {Function} replace A function of type `(err) => Stream` that takes
494 * the error that occurred on the input stream or on the previous replacement
495 * stream and returns a new stream. The output stream will behave like the
496 * stream that this function returns.
497 * @return {Stream}
498 */
499 replaceError(replace: (err: any) => Stream<T>): Stream<T>;
500 /**
501 * Flattens a "stream of streams", handling only one nested stream at a time
502 * (no concurrency).
503 *
504 * If the input stream is a stream that emits streams, then this operator will
505 * return an output stream which is a flat stream: emits regular events. The
506 * flattening happens without concurrency. It works like this: when the input
507 * stream emits a nested stream, *flatten* will start imitating that nested
508 * one. However, as soon as the next nested stream is emitted on the input
509 * stream, *flatten* will forget the previous nested one it was imitating, and
510 * will start imitating the new nested one.
511 *
512 * Marble diagram:
513 *
514 * ```text
515 * --+--------+---------------
516 * \ \
517 * \ ----1----2---3--
518 * --a--b----c----d--------
519 * flatten
520 * -----a--b------1----2---3--
521 * ```
522 *
523 * @return {Stream}
524 */
525 flatten<R>(this: Stream<Stream<R>>): T;
526 /**
527 * Passes the input stream to a custom operator, to produce an output stream.
528 *
529 * *compose* is a handy way of using an existing function in a chained style.
530 * Instead of writing `outStream = f(inStream)` you can write
531 * `outStream = inStream.compose(f)`.
532 *
533 * @param {function} operator A function that takes a stream as input and
534 * returns a stream as well.
535 * @return {Stream}
536 */
537 compose<U>(operator: (stream: Stream<T>) => Stream<U>): Stream<U>;
538 /**
539 * Returns an output stream that behaves like the input stream, but also
540 * remembers the most recent event that happens on the input stream, so that a
541 * newly added listener will immediately receive that memorised event.
542 *
543 * @return {MemoryStream}
544 */
545 remember(): MemoryStream<T>;
546 debug(): Stream<T>;
547 debug(labelOrSpy: string): Stream<T>;
548 debug(labelOrSpy: (t: T) => any): Stream<T>;
549 /**
550 * *imitate* changes this current Stream to emit the same events that the
551 * `other` given Stream does. This method returns nothing.
552 *
553 * This method exists to allow one thing: **circular dependency of streams**.
554 * For instance, let's imagine that for some reason you need to create a
555 * circular dependency where stream `first$` depends on stream `second$`
556 * which in turn depends on `first$`:
557 *
558 * <!-- skip-example -->
559 * ```js
560 * import delay from 'xstream/extra/delay'
561 *
562 * var first$ = second$.map(x => x * 10).take(3);
563 * var second$ = first$.map(x => x + 1).startWith(1).compose(delay(100));
564 * ```
565 *
566 * However, that is invalid JavaScript, because `second$` is undefined
567 * on the first line. This is how *imitate* can help solve it:
568 *
569 * ```js
570 * import delay from 'xstream/extra/delay'
571 *
572 * var secondProxy$ = xs.create();
573 * var first$ = secondProxy$.map(x => x * 10).take(3);
574 * var second$ = first$.map(x => x + 1).startWith(1).compose(delay(100));
575 * secondProxy$.imitate(second$);
576 * ```
577 *
578 * We create `secondProxy$` before the others, so it can be used in the
579 * declaration of `first$`. Then, after both `first$` and `second$` are
580 * defined, we hook `secondProxy$` with `second$` with `imitate()` to tell
581 * that they are "the same". `imitate` will not trigger the start of any
582 * stream, it just binds `secondProxy$` and `second$` together.
583 *
584 * The following is an example where `imitate()` is important in Cycle.js
585 * applications. A parent component contains some child components. A child
586 * has an action stream which is given to the parent to define its state:
587 *
588 * <!-- skip-example -->
589 * ```js
590 * const childActionProxy$ = xs.create();
591 * const parent = Parent({...sources, childAction$: childActionProxy$});
592 * const childAction$ = parent.state$.map(s => s.child.action$).flatten();
593 * childActionProxy$.imitate(childAction$);
594 * ```
595 *
596 * Note, though, that **`imitate()` does not support MemoryStreams**. If we
597 * would attempt to imitate a MemoryStream in a circular dependency, we would
598 * either get a race condition (where the symptom would be "nothing happens")
599 * or an infinite cyclic emission of values. It's useful to think about
600 * MemoryStreams as cells in a spreadsheet. It doesn't make any sense to
601 * define a spreadsheet cell `A1` with a formula that depends on `B1` and
602 * cell `B1` defined with a formula that depends on `A1`.
603 *
604 * If you find yourself wanting to use `imitate()` with a
605 * MemoryStream, you should rework your code around `imitate()` to use a
606 * Stream instead. Look for the stream in the circular dependency that
607 * represents an event stream, and that would be a candidate for creating a
608 * proxy Stream which then imitates the target Stream.
609 *
610 * @param {Stream} target The other stream to imitate on the current one. Must
611 * not be a MemoryStream.
612 */
613 imitate(target: Stream<T>): void;
614 /**
615 * Forces the Stream to emit the given value to its listeners.
616 *
617 * As the name indicates, if you use this, you are most likely doing something
618 * The Wrong Way. Please try to understand the reactive way before using this
619 * method. Use it only when you know what you are doing.
620 *
621 * @param value The "next" value you want to broadcast to all listeners of
622 * this Stream.
623 */
624 shamefullySendNext(value: T): void;
625 /**
626 * Forces the Stream to emit the given error to its listeners.
627 *
628 * As the name indicates, if you use this, you are most likely doing something
629 * The Wrong Way. Please try to understand the reactive way before using this
630 * method. Use it only when you know what you are doing.
631 *
632 * @param {any} error The error you want to broadcast to all the listeners of
633 * this Stream.
634 */
635 shamefullySendError(error: any): void;
636 /**
637 * Forces the Stream to emit the "completed" event to its listeners.
638 *
639 * As the name indicates, if you use this, you are most likely doing something
640 * The Wrong Way. Please try to understand the reactive way before using this
641 * method. Use it only when you know what you are doing.
642 */
643 shamefullySendComplete(): void;
644 /**
645 * Adds a "debug" listener to the stream. There can only be one debug
646 * listener, that's why this is 'setDebugListener'. To remove the debug
647 * listener, just call setDebugListener(null).
648 *
649 * A debug listener is like any other listener. The only difference is that a
650 * debug listener is "stealthy": its presence/absence does not trigger the
651 * start/stop of the stream (or the producer inside the stream). This is
652 * useful so you can inspect what is going on without changing the behavior
653 * of the program. If you have an idle stream and you add a normal listener to
654 * it, the stream will start executing. But if you set a debug listener on an
655 * idle stream, it won't start executing (not until the first normal listener
656 * is added).
657 *
658 * As the name indicates, we don't recommend using this method to build app
659 * logic. In fact, in most cases the debug operator works just fine. Only use
660 * this one if you know what you're doing.
661 *
662 * @param {Listener<T>} listener
663 */
664 setDebugListener(listener: Partial<Listener<T>> | null | undefined): void;
665}
666export declare class MemoryStream<T> extends Stream<T> {
667 private _v;
668 private _has;
669 constructor(producer: InternalProducer<T>);
670 _n(x: T): void;
671 _add(il: InternalListener<T>): void;
672 _stopNow(): void;
673 _x(): void;
674 map<U>(project: (t: T) => U): MemoryStream<U>;
675 mapTo<U>(projectedValue: U): MemoryStream<U>;
676 take(amount: number): MemoryStream<T>;
677 endWhen(other: Stream<any>): MemoryStream<T>;
678 replaceError(replace: (err: any) => Stream<T>): MemoryStream<T>;
679 remember(): MemoryStream<T>;
680 debug(): MemoryStream<T>;
681 debug(labelOrSpy: string): MemoryStream<T>;
682 debug(labelOrSpy: (t: T) => any): MemoryStream<T>;
683}
684export { NO, NO_IL };
685export default Stream;
686
\No newline at end of file