1 | import { EventStream } from "./observable";
|
2 | import Observable from "./observable";
|
3 | import { EventSink, Unsub } from "./types";
|
4 | import { Reply } from "./reply";
|
5 | interface Subscription<V> {
|
6 | input: Observable<V>;
|
7 | unsub: Unsub | undefined;
|
8 | }
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | export default class Bus<V> extends EventStream<V> {
|
17 |
|
18 | sink?: EventSink<V>;
|
19 |
|
20 | pushing: boolean;
|
21 |
|
22 | pushQueue?: V[];
|
23 |
|
24 | ended: boolean;
|
25 |
|
26 | subscriptions: Subscription<V>[];
|
27 | constructor();
|
28 | /**
|
29 | Plugs the given stream as an input to the Bus. All events from
|
30 | the given stream will be delivered to the subscribers of the Bus.
|
31 | Returns a function that can be used to unplug the same stream.
|
32 |
|
33 | The plug method practically allows you to merge in other streams after
|
34 | the creation of the Bus.
|
35 |
|
36 | * @returns a function that can be called to "unplug" the source from Bus.
|
37 | */
|
38 | plug<V2 extends V>(input: Observable<V2>): (() => void) | undefined;
|
39 | /**
|
40 | Ends the stream. Sends an [End](end.html) event to all subscribers.
|
41 | After this call, there'll be no more events to the subscribers.
|
42 | Also, the [`push`](#push), [`error`](#error) and [`plug`](#plug) methods have no effect.
|
43 | */
|
44 | end(): Reply;
|
45 | /**
|
46 | * Pushes a new value to the stream.
|
47 | */
|
48 | push(value: V): Reply;
|
49 | /**
|
50 | * Pushes an error to this stream.
|
51 | */
|
52 | error(error: any): Reply;
|
53 | /** @hidden */
|
54 | unsubAll(): void;
|
55 | /** @hidden */
|
56 | subscribeAll(newSink: EventSink<V>): () => void;
|
57 | /** @hidden */
|
58 | guardedSink(input: Observable<V>): EventSink<V>;
|
59 | /** @hidden */
|
60 | subscribeInput(subscription: Subscription<V>): Unsub;
|
61 | /** @hidden */
|
62 | unsubscribeInput(input: Observable<any>): void;
|
63 | }
|
64 | export {};
|