Class Operation (4.0.3)

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

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

Parameter
Name
Description
callback
Returns
Type
Description
void

promise()

  promise 
 () 
 : 
  
 Promise<unknown> 
 ; 
 

Wraps the complete and error events in a Promise.

{Promise}

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

Returns
Type
Description
Promise <void>
Design a Mobile Site
View Site in Mobile | Classic
Share by: