| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | */ |
| 7 | |
| 8 | import type {Disposable, MessageBusStatus} from './types'; |
| 9 | |
| 10 | export type {MessageBusStatus}; |
| 11 | |
| 12 | /* |
| 13 | * Abstraction for the bidirectional communication channel between the |
| 14 | * ISL UI and the "business logic" that talks to Sapling, Watchman, etc. |
| 15 | * |
| 16 | * Every platform (BrowserPlatform VSCodeWebviewPlatform, etc) will have a single MessageBus instance. |
| 17 | */ |
| 18 | export interface MessageBus { |
| 19 | onMessage(handler: (event: MessageEvent) => void | Promise<void>): Disposable; |
| 20 | onChangeStatus(handler: (newStatus: MessageBusStatus) => void | Promise<void>): Disposable; |
| 21 | postMessage(message: string): void; |
| 22 | |
| 23 | /** Force disconnect (for debugging), for supported implementations. */ |
| 24 | forceDisconnect?(durationMs?: number): void; |
| 25 | } |
| 26 | |