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