addons/isl/src/MessageBus.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {Disposable, MessageBusStatus} from './types';
b69ab319
b69ab3110export type {MessageBusStatus};
b69ab3111
b69ab3112/*
b69ab3113 * Abstraction for the bidirectional communication channel between the
b69ab3114 * ISL UI and the "business logic" that talks to Sapling, Watchman, etc.
b69ab3115 *
b69ab3116 * Every platform (BrowserPlatform VSCodeWebviewPlatform, etc) will have a single MessageBus instance.
b69ab3117 */
b69ab3118export interface MessageBus {
b69ab3119 onMessage(handler: (event: MessageEvent) => void | Promise<void>): Disposable;
b69ab3120 onChangeStatus(handler: (newStatus: MessageBusStatus) => void | Promise<void>): Disposable;
b69ab3121 postMessage(message: string): void;
b69ab3122
b69ab3123 /** Force disconnect (for debugging), for supported implementations. */
b69ab3124 forceDisconnect?(durationMs?: number): void;
b69ab3125}