src/normalCalls/normalApiCaller.ts
Creates an API caller for regular unary methods.
Methods |
call | |||||||||||||||
call(apiCall: SimpleCallbackFunction, argument: literal type, settings: literal type, canceller: OngoingCallPromise)
|
|||||||||||||||
Defined in src/normalCalls/normalApiCaller.ts:54
|
|||||||||||||||
Parameters :
Returns :
void
|
fail | |||||||||
fail(canceller: OngoingCallPromise, err: GoogleError)
|
|||||||||
Defined in src/normalCalls/normalApiCaller.ts:63
|
|||||||||
Parameters :
Returns :
void
|
init | |||||||||
init(settings: ApiCallerSettings, callback?: APICallback)
|
|||||||||
Defined in src/normalCalls/normalApiCaller.ts:40
|
|||||||||
Parameters :
Returns :
OngoingCallPromise | OngoingCall
|
result | ||||||
result(canceller: OngoingCallPromise)
|
||||||
Defined in src/normalCalls/normalApiCaller.ts:67
|
||||||
Parameters :
Returns :
any
|
wrap | ||||||
wrap(func: GRPCCall)
|
||||||
Defined in src/normalCalls/normalApiCaller.ts:50
|
||||||
Parameters :
Returns :
GRPCCall
|
import {APICaller, ApiCallerSettings} from '../apiCaller';
import {APICallback, GRPCCall, SimpleCallbackFunction} from '../apitypes';
import {OngoingCall, OngoingCallPromise} from '../call';
import {GoogleError} from '../googleError';
/**
* Creates an API caller for regular unary methods.
*/
export class NormalApiCaller implements APICaller {
init(
settings: ApiCallerSettings,
callback?: APICallback
): OngoingCallPromise | OngoingCall {
if (callback) {
return new OngoingCall(callback);
}
return new OngoingCallPromise(settings.promise);
}
wrap(func: GRPCCall): GRPCCall {
return func;
}
call(
apiCall: SimpleCallbackFunction,
argument: {},
settings: {},
canceller: OngoingCallPromise
): void {
canceller.call(apiCall, argument);
}
fail(canceller: OngoingCallPromise, err: GoogleError): void {
canceller.callback!(err);
}
result(canceller: OngoingCallPromise) {
return canceller.promise;
}
}