1 | /**
|
2 | * Copyright 2020 Google LLC
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import { APICallback, RequestType, ResultTuple, SimpleCallbackFunction } from './apitypes';
|
17 | export declare class OngoingCall {
|
18 | callback: APICallback;
|
19 | cancelFunc?: () => void;
|
20 | completed: boolean;
|
21 | /**
|
22 | * OngoingCall manages callback, API calls, and cancellation
|
23 | * of the API calls.
|
24 | * @param {APICallback=} callback
|
25 | * The callback to be called asynchronously when the API call
|
26 | * finishes.
|
27 | * @constructor
|
28 | * @property {APICallback} callback
|
29 | * The callback function to be called.
|
30 | * @private
|
31 | */
|
32 | constructor(callback: APICallback);
|
33 | /**
|
34 | * Cancels the ongoing promise.
|
35 | */
|
36 | cancel(): void;
|
37 | /**
|
38 | * Call calls the specified function. Result will be used to fulfill
|
39 | * the promise.
|
40 | *
|
41 | * @param {SimpleCallbackFunction} func
|
42 | * A function for an API call.
|
43 | * @param {Object} argument
|
44 | * A request object.
|
45 | */
|
46 | call(func: SimpleCallbackFunction, argument: RequestType): void;
|
47 | }
|
48 | export interface CancellablePromise<T> extends Promise<T> {
|
49 | cancel(): void;
|
50 | }
|
51 | export declare class OngoingCallPromise extends OngoingCall {
|
52 | promise: CancellablePromise<ResultTuple>;
|
53 | /**
|
54 | * GaxPromise is GRPCCallbackWrapper, but it holds a promise when
|
55 | * the API call finishes.
|
56 | * @constructor
|
57 | * @private
|
58 | */
|
59 | constructor();
|
60 | }
|