Inheritance
ServiceObject<T> > OperationPackage
@google-cloud/commonConstructors
(constructor)(config)
constructor(config: ServiceObjectConfig);
An Operation object allows you to interact with APIs that take longer to process things.
module:common/operation
Name | Description |
config |
ServiceObjectConfig
Configuration object. |
Properties
completeListeners
completeListeners: number;
hasActiveListeners
hasActiveListeners: boolean;
Methods
listenForEvents_()
protected listenForEvents_(): void;
Begin listening for events on the operation. This method keeps track of how many "complete" listeners are registered and removed, making sure polling is handled automatically.
As long as there is one active "complete" listener, the connection is open. When there are no more listeners, the polling stops.
Type | Description |
void |
poll_(callback)
protected poll_(callback: MetadataCallback): void;
Poll for a status update. Returns null for an incomplete status, and metadata for a complete status.
Name | Description |
callback |
MetadataCallback
|
Type | Description |
void |
promise()
promise(): Promise<unknown>;
Wraps the complete
and error
events in a Promise.
{Promise}
Type | Description |
Promise<unknown> |
startPolling_()
protected startPolling_(): Promise<void>;
Poll getMetadata
to check the operation's status. This runs a loop to ping the API on an interval.
Note: This method is automatically called once a "complete" event handler is registered on the operation.
Type | Description |
Promise<void> |