UNPKG

25.9 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 * @factory true
300 * @param {Stream} stream1 A stream to combine together with other streams.
301 * @param {Stream} stream2 A stream to combine together with other streams.
302 * Multiple streams, not just two, may be given as arguments.
303 * @return {Stream}
304 */
305 static combine: CombineSignature;
306 protected _map<U>(project: (t: T) => U): Stream<U> | MemoryStream<U>;
307 /**
308 * Transforms each event from the input Stream through a `project` function,
309 * to get a Stream that emits those transformed events.
310 *
311 * Marble diagram:
312 *
313 * ```text
314 * --1---3--5-----7------
315 * map(i => i * 10)
316 * --10--30-50----70-----
317 * ```
318 *
319 * @param {Function} project A function of type `(t: T) => U` that takes event
320 * `t` of type `T` from the input Stream and produces an event of type `U`, to
321 * be emitted on the output Stream.
322 * @return {Stream}
323 */
324 map<U>(project: (t: T) => U): Stream<U>;
325 /**
326 * It's like `map`, but transforms each input event to always the same
327 * constant value on the output Stream.
328 *
329 * Marble diagram:
330 *
331 * ```text
332 * --1---3--5-----7-----
333 * mapTo(10)
334 * --10--10-10----10----
335 * ```
336 *
337 * @param projectedValue A value to emit on the output Stream whenever the
338 * input Stream emits any value.
339 * @return {Stream}
340 */
341 mapTo<U>(projectedValue: U): Stream<U>;
342 filter<S extends T>(passes: (t: T) => t is S): Stream<S>;
343 filter(passes: (t: T) => boolean): Stream<T>;
344 /**
345 * Lets the first `amount` many events from the input stream pass to the
346 * output stream, then makes the output stream complete.
347 *
348 * Marble diagram:
349 *
350 * ```text
351 * --a---b--c----d---e--
352 * take(3)
353 * --a---b--c|
354 * ```
355 *
356 * @param {number} amount How many events to allow from the input stream
357 * before completing the output stream.
358 * @return {Stream}
359 */
360 take(amount: number): Stream<T>;
361 /**
362 * Ignores the first `amount` many events from the input stream, and then
363 * after that starts forwarding events from the input stream to the output
364 * stream.
365 *
366 * Marble diagram:
367 *
368 * ```text
369 * --a---b--c----d---e--
370 * drop(3)
371 * --------------d---e--
372 * ```
373 *
374 * @param {number} amount How many events to ignore from the input stream
375 * before forwarding all events from the input stream to the output stream.
376 * @return {Stream}
377 */
378 drop(amount: number): Stream<T>;
379 /**
380 * When the input stream completes, the output stream will emit the last event
381 * emitted by the input stream, and then will also complete.
382 *
383 * Marble diagram:
384 *
385 * ```text
386 * --a---b--c--d----|
387 * last()
388 * -----------------d|
389 * ```
390 *
391 * @return {Stream}
392 */
393 last(): Stream<T>;
394 /**
395 * Prepends the given `initial` value to the sequence of events emitted by the
396 * input stream. The returned stream is a MemoryStream, which means it is
397 * already `remember()`'d.
398 *
399 * Marble diagram:
400 *
401 * ```text
402 * ---1---2-----3---
403 * startWith(0)
404 * 0--1---2-----3---
405 * ```
406 *
407 * @param initial The value or event to prepend.
408 * @return {MemoryStream}
409 */
410 startWith(initial: T): MemoryStream<T>;
411 /**
412 * Uses another stream to determine when to complete the current stream.
413 *
414 * When the given `other` stream emits an event or completes, the output
415 * stream will complete. Before that happens, the output stream will behaves
416 * like the input stream.
417 *
418 * Marble diagram:
419 *
420 * ```text
421 * ---1---2-----3--4----5----6---
422 * endWhen( --------a--b--| )
423 * ---1---2-----3--4--|
424 * ```
425 *
426 * @param other Some other stream that is used to know when should the output
427 * stream of this operator complete.
428 * @return {Stream}
429 */
430 endWhen(other: Stream<any>): Stream<T>;
431 /**
432 * "Folds" the stream onto itself.
433 *
434 * Combines events from the past throughout
435 * the entire execution of the input stream, allowing you to accumulate them
436 * together. It's essentially like `Array.prototype.reduce`. The returned
437 * stream is a MemoryStream, which means it is already `remember()`'d.
438 *
439 * The output stream starts by emitting the `seed` which you give as argument.
440 * Then, when an event happens on the input stream, it is combined with that
441 * seed value through the `accumulate` function, and the output value is
442 * emitted on the output stream. `fold` remembers that output value as `acc`
443 * ("accumulator"), and then when a new input event `t` happens, `acc` will be
444 * combined with that to produce the new `acc` and so forth.
445 *
446 * Marble diagram:
447 *
448 * ```text
449 * ------1-----1--2----1----1------
450 * fold((acc, x) => acc + x, 3)
451 * 3-----4-----5--7----8----9------
452 * ```
453 *
454 * @param {Function} accumulate A function of type `(acc: R, t: T) => R` that
455 * takes the previous accumulated value `acc` and the incoming event from the
456 * input stream and produces the new accumulated value.
457 * @param seed The initial accumulated value, of type `R`.
458 * @return {MemoryStream}
459 */
460 fold<R>(accumulate: (acc: R, t: T) => R, seed: R): MemoryStream<R>;
461 /**
462 * Replaces an error with another stream.
463 *
464 * When (and if) an error happens on the input stream, instead of forwarding
465 * that error to the output stream, *replaceError* will call the `replace`
466 * function which returns the stream that the output stream will replicate.
467 * And, in case that new stream also emits an error, `replace` will be called
468 * again to get another stream to start replicating.
469 *
470 * Marble diagram:
471 *
472 * ```text
473 * --1---2-----3--4-----X
474 * replaceError( () => --10--| )
475 * --1---2-----3--4--------10--|
476 * ```
477 *
478 * @param {Function} replace A function of type `(err) => Stream` that takes
479 * the error that occurred on the input stream or on the previous replacement
480 * stream and returns a new stream. The output stream will behave like the
481 * stream that this function returns.
482 * @return {Stream}
483 */
484 replaceError(replace: (err: any) => Stream<T>): Stream<T>;
485 /**
486 * Flattens a "stream of streams", handling only one nested stream at a time
487 * (no concurrency).
488 *
489 * If the input stream is a stream that emits streams, then this operator will
490 * return an output stream which is a flat stream: emits regular events. The
491 * flattening happens without concurrency. It works like this: when the input
492 * stream emits a nested stream, *flatten* will start imitating that nested
493 * one. However, as soon as the next nested stream is emitted on the input
494 * stream, *flatten* will forget the previous nested one it was imitating, and
495 * will start imitating the new nested one.
496 *
497 * Marble diagram:
498 *
499 * ```text
500 * --+--------+---------------
501 * \ \
502 * \ ----1----2---3--
503 * --a--b----c----d--------
504 * flatten
505 * -----a--b------1----2---3--
506 * ```
507 *
508 * @return {Stream}
509 */
510 flatten<R>(this: Stream<Stream<R>>): T;
511 /**
512 * Passes the input stream to a custom operator, to produce an output stream.
513 *
514 * *compose* is a handy way of using an existing function in a chained style.
515 * Instead of writing `outStream = f(inStream)` you can write
516 * `outStream = inStream.compose(f)`.
517 *
518 * @param {function} operator A function that takes a stream as input and
519 * returns a stream as well.
520 * @return {Stream}
521 */
522 compose<U>(operator: (stream: Stream<T>) => U): U;
523 /**
524 * Returns an output stream that behaves like the input stream, but also
525 * remembers the most recent event that happens on the input stream, so that a
526 * newly added listener will immediately receive that memorised event.
527 *
528 * @return {MemoryStream}
529 */
530 remember(): MemoryStream<T>;
531 debug(): Stream<T>;
532 debug(labelOrSpy: string): Stream<T>;
533 debug(labelOrSpy: (t: T) => any): Stream<T>;
534 /**
535 * *imitate* changes this current Stream to emit the same events that the
536 * `other` given Stream does. This method returns nothing.
537 *
538 * This method exists to allow one thing: **circular dependency of streams**.
539 * For instance, let's imagine that for some reason you need to create a
540 * circular dependency where stream `first$` depends on stream `second$`
541 * which in turn depends on `first$`:
542 *
543 * <!-- skip-example -->
544 * ```js
545 * import delay from 'xstream/extra/delay'
546 *
547 * var first$ = second$.map(x => x * 10).take(3);
548 * var second$ = first$.map(x => x + 1).startWith(1).compose(delay(100));
549 * ```
550 *
551 * However, that is invalid JavaScript, because `second$` is undefined
552 * on the first line. This is how *imitate* can help solve it:
553 *
554 * ```js
555 * import delay from 'xstream/extra/delay'
556 *
557 * var secondProxy$ = xs.create();
558 * var first$ = secondProxy$.map(x => x * 10).take(3);
559 * var second$ = first$.map(x => x + 1).startWith(1).compose(delay(100));
560 * secondProxy$.imitate(second$);
561 * ```
562 *
563 * We create `secondProxy$` before the others, so it can be used in the
564 * declaration of `first$`. Then, after both `first$` and `second$` are
565 * defined, we hook `secondProxy$` with `second$` with `imitate()` to tell
566 * that they are "the same". `imitate` will not trigger the start of any
567 * stream, it just binds `secondProxy$` and `second$` together.
568 *
569 * The following is an example where `imitate()` is important in Cycle.js
570 * applications. A parent component contains some child components. A child
571 * has an action stream which is given to the parent to define its state:
572 *
573 * <!-- skip-example -->
574 * ```js
575 * const childActionProxy$ = xs.create();
576 * const parent = Parent({...sources, childAction$: childActionProxy$});
577 * const childAction$ = parent.state$.map(s => s.child.action$).flatten();
578 * childActionProxy$.imitate(childAction$);
579 * ```
580 *
581 * Note, though, that **`imitate()` does not support MemoryStreams**. If we
582 * would attempt to imitate a MemoryStream in a circular dependency, we would
583 * either get a race condition (where the symptom would be "nothing happens")
584 * or an infinite cyclic emission of values. It's useful to think about
585 * MemoryStreams as cells in a spreadsheet. It doesn't make any sense to
586 * define a spreadsheet cell `A1` with a formula that depends on `B1` and
587 * cell `B1` defined with a formula that depends on `A1`.
588 *
589 * If you find yourself wanting to use `imitate()` with a
590 * MemoryStream, you should rework your code around `imitate()` to use a
591 * Stream instead. Look for the stream in the circular dependency that
592 * represents an event stream, and that would be a candidate for creating a
593 * proxy Stream which then imitates the target Stream.
594 *
595 * @param {Stream} target The other stream to imitate on the current one. Must
596 * not be a MemoryStream.
597 */
598 imitate(target: Stream<T>): void;
599 /**
600 * Forces the Stream to emit the given value to its listeners.
601 *
602 * As the name indicates, if you use this, you are most likely doing something
603 * The Wrong Way. Please try to understand the reactive way before using this
604 * method. Use it only when you know what you are doing.
605 *
606 * @param value The "next" value you want to broadcast to all listeners of
607 * this Stream.
608 */
609 shamefullySendNext(value: T): void;
610 /**
611 * Forces the Stream to emit the given error to its listeners.
612 *
613 * As the name indicates, if you use this, you are most likely doing something
614 * The Wrong Way. Please try to understand the reactive way before using this
615 * method. Use it only when you know what you are doing.
616 *
617 * @param {any} error The error you want to broadcast to all the listeners of
618 * this Stream.
619 */
620 shamefullySendError(error: any): void;
621 /**
622 * Forces the Stream to emit the "completed" event to its listeners.
623 *
624 * As the name indicates, if you use this, you are most likely doing something
625 * The Wrong Way. Please try to understand the reactive way before using this
626 * method. Use it only when you know what you are doing.
627 */
628 shamefullySendComplete(): void;
629 /**
630 * Adds a "debug" listener to the stream. There can only be one debug
631 * listener, that's why this is 'setDebugListener'. To remove the debug
632 * listener, just call setDebugListener(null).
633 *
634 * A debug listener is like any other listener. The only difference is that a
635 * debug listener is "stealthy": its presence/absence does not trigger the
636 * start/stop of the stream (or the producer inside the stream). This is
637 * useful so you can inspect what is going on without changing the behavior
638 * of the program. If you have an idle stream and you add a normal listener to
639 * it, the stream will start executing. But if you set a debug listener on an
640 * idle stream, it won't start executing (not until the first normal listener
641 * is added).
642 *
643 * As the name indicates, we don't recommend using this method to build app
644 * logic. In fact, in most cases the debug operator works just fine. Only use
645 * this one if you know what you're doing.
646 *
647 * @param {Listener<T>} listener
648 */
649 setDebugListener(listener: Partial<Listener<T>> | null | undefined): void;
650}
651export declare class MemoryStream<T> extends Stream<T> {
652 private _v;
653 private _has;
654 constructor(producer: InternalProducer<T>);
655 _n(x: T): void;
656 _add(il: InternalListener<T>): void;
657 _stopNow(): void;
658 _x(): void;
659 map<U>(project: (t: T) => U): MemoryStream<U>;
660 mapTo<U>(projectedValue: U): MemoryStream<U>;
661 take(amount: number): MemoryStream<T>;
662 endWhen(other: Stream<any>): MemoryStream<T>;
663 replaceError(replace: (err: any) => Stream<T>): MemoryStream<T>;
664 remember(): MemoryStream<T>;
665 debug(): MemoryStream<T>;
666 debug(labelOrSpy: string): MemoryStream<T>;
667 debug(labelOrSpy: (t: T) => any): MemoryStream<T>;
668}
669export { NO, NO_IL };
670declare const xs: typeof Stream;
671export default xs;
672
\No newline at end of file