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 | 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 | }
|
651 | export 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 | }
|
669 | export { NO, NO_IL };
|
670 | declare const xs: typeof Stream;
|
671 | export default xs;
|
672 |
|
\ | No newline at end of file |