1 | declare const NO: {};
|
2 | export interface InternalListener<T> {
|
3 | _n: (v: T) => void;
|
4 | _e: (err: any) => void;
|
5 | _c: () => void;
|
6 | }
|
7 | declare const NO_IL: InternalListener<any>;
|
8 | export interface InternalProducer<T> {
|
9 | _start: (listener: InternalListener<T>) => void;
|
10 | _stop: () => void;
|
11 | }
|
12 | export interface OutSender<T> {
|
13 | out: Stream<T>;
|
14 | }
|
15 | export 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 | }
|
20 | export interface Aggregator<T, U> extends InternalProducer<U>, OutSender<U> {
|
21 | type: string;
|
22 | insArr: Array<Stream<T>>;
|
23 | _start: (out: Stream<U>) => void;
|
24 | }
|
25 | export interface Producer<T> {
|
26 | start: (listener: Listener<T>) => void;
|
27 | stop: () => void;
|
28 | }
|
29 | export interface Listener<T> {
|
30 | next: (x: T) => void;
|
31 | error: (err: any) => void;
|
32 | complete: () => void;
|
33 | }
|
34 | export interface Subscription {
|
35 | unsubscribe(): void;
|
36 | }
|
37 | export interface Observable<T> {
|
38 | subscribe(listener: Listener<T>): Subscription;
|
39 | }
|
40 | export 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 | }
|
54 | export 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 | }
|
68 | export 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 |
|
95 |
|
96 |
|
97 |
|
98 | removeListener(listener: Partial<Listener<T>>): void;
|
99 | |
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 | subscribe(listener: Listener<T>): Subscription;
|
107 | |
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 | static create<T>(producer?: Producer<T>): Stream<T>;
|
116 | |
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 | static createWithMemory<T>(producer?: Producer<T>): MemoryStream<T>;
|
125 | |
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 |
|
137 |
|
138 | static never(): Stream<any>;
|
139 | |
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 | static empty(): Stream<any>;
|
154 | |
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 | static throw(error: any): Stream<any>;
|
171 | |
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 | static from<T>(input: PromiseLike<T> | Stream<T> | Array<T> | Observable<T>): Stream<T>;
|
179 | |
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 | static of<T>(...items: Array<T>): Stream<T>;
|
197 | |
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 |
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 | static fromArray<T>(array: Array<T>): Stream<T>;
|
213 | |
214 |
|
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 |
|
223 |
|
224 |
|
225 |
|
226 |
|
227 |
|
228 |
|
229 | static fromPromise<T>(promise: PromiseLike<T>): Stream<T>;
|
230 | |
231 |
|
232 |
|
233 |
|
234 |
|
235 |
|
236 |
|
237 | static fromObservable<T>(obs: {
|
238 | subscribe: any;
|
239 | }): Stream<T>;
|
240 | |
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 |
|
256 | static periodic(period: number): Stream<number>;
|
257 | |
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 |
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 | static merge: MergeSignature;
|
280 | |
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 |
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 |
|
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 | }
|
666 | export 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 | }
|
684 | export { NO, NO_IL };
|
685 | export default Stream;
|
686 |
|
\ | No newline at end of file |