@sussudio/platform
Version:
Internal APIs for VS Code's service injection the base services.
41 lines (39 loc) • 1.54 kB
text/typescript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable } from '@sussudio/base/common/lifecycle.mjs';
import { ILogService } from '../../log/common/log.mjs';
/**
* A helper class to track requests that have replies. Using this it's easy to implement an event
* that accepts a reply.
*/
export declare class RequestStore<T, RequestArgs> extends Disposable {
private readonly _logService;
private _lastRequestId;
private readonly _timeout;
private _pendingRequests;
private _pendingRequestDisposables;
private readonly _onCreateRequest;
readonly onCreateRequest: import('@sussudio/base/common/event.mjs').Event<
RequestArgs & {
requestId: number;
}
>;
/**
* @param timeout How long in ms to allow requests to go unanswered for, undefined will use the
* default (15 seconds).
*/
constructor(timeout: number | undefined, _logService: ILogService);
/**
* Creates a request.
* @param args The arguments to pass to the onCreateRequest event.
*/
createRequest(args: RequestArgs): Promise<T>;
/**
* Accept a reply to a request.
* @param requestId The request ID originating from the onCreateRequest event.
* @param data The reply data.
*/
acceptReply(requestId: number, data: T): void;
}