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
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.
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.
void
promise()
promise
()
:
Promise<unknown>
;
Wraps the complete
and error
events in a Promise.
{Promise}
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.
Promise
<void>