Class Operation (3.9.0)

Inheritance

ServiceObject<T> > Operation

Package

@google-cloud/common

Constructors

(constructor)(config)

constructor(config: ServiceObjectConfig);

An Operation object allows you to interact with APIs that take longer to process things.

module:common/operation

Parameter
NameDescription
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.

Returns
TypeDescription
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.

Parameter
NameDescription
callback MetadataCallback
Returns
TypeDescription
void

promise()

promise(): Promise<unknown>;

Wraps the complete and error events in a Promise.

{Promise}

Returns
TypeDescription
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.

Returns
TypeDescription
Promise<void>