UNPKG

2.05 kBTypeScriptView Raw
1import { JSONObject, ReadonlyJSONObject } from '@lumino/coreutils';
2import { IDisposable } from '@lumino/disposable';
3import { IStream } from '@lumino/signaling';
4import { ServerConnection } from '../serverconnection';
5/**
6 * The events API service manager.
7 */
8export declare class EventManager implements IDisposable {
9 /**
10 * Create a new event manager.
11 */
12 constructor(options?: EventManager.IOptions);
13 /**
14 * The server settings used to make API requests.
15 */
16 readonly serverSettings: ServerConnection.ISettings;
17 /**
18 * Whether the event manager is disposed.
19 */
20 get isDisposed(): boolean;
21 /**
22 * An event stream that emits and yields each new event.
23 */
24 get stream(): Event.Stream;
25 /**
26 * Dispose the event manager.
27 */
28 dispose(): void;
29 /**
30 * Post an event request to be emitted by the event bus.
31 */
32 emit(event: Event.Request): Promise<void>;
33 /**
34 * Subscribe to event bus emissions.
35 */
36 private _subscribe;
37 private _poll;
38 private _socket;
39 private _stream;
40}
41/**
42 * A namespace for `EventManager` statics.
43 */
44export declare namespace EventManager {
45 /**
46 * The instantiation options for an event manager.
47 */
48 interface IOptions {
49 /**
50 * The server settings used to make API requests.
51 */
52 serverSettings?: ServerConnection.ISettings;
53 }
54}
55/**
56 * A namespace for event API interfaces.
57 */
58export declare namespace Event {
59 /**
60 * The event emission type.
61 */
62 type Emission = ReadonlyJSONObject & {
63 schema_id: string;
64 };
65 /**
66 * The event request type.
67 */
68 type Request = {
69 data: JSONObject;
70 schema_id: string;
71 version: string;
72 };
73 /**
74 * An event stream with the characteristics of a signal and an async iterator.
75 */
76 type Stream = IStream<IManager, Emission>;
77 /**
78 * The interface for the event bus front-end.
79 */
80 interface IManager extends EventManager {
81 }
82}