Cloud Firestore API - Class Google::Cloud::Firestore::Promise::Future (v2.16.0)

Reference documentation and code samples for the Cloud Firestore API class Google::Cloud::Firestore::Promise::Future.

Future

A Future object represents a value which will become available in future. May reject with a reason instead, e.g. when the tasks raises an exception.

Inherits

  • Object

Methods

#fulfilled?

def fulfilled?() -> Boolean

Is it in fulfilled state?

Returns
  • (Boolean)

#initialize

def initialize(future) -> Future

Initialize the future object

Returns
  • (Future) — a new instance of Future

#reason

def reason(timeout = nil, timeout_value = nil) -> Object, timeout_value

Returns reason of future's rejection.

Returns
  • (Object, timeout_value) — the reason, or timeout_value on timeout, or nil on fulfillment.

#rejected?

def rejected?() -> Boolean

Is it in rejected state?

Returns
  • (Boolean)

#rescue

def rescue(*args, &task) -> Future

Chains the task to be executed synchronously on executor after it rejects. Does not run the task if it fulfills. It will resolve though, triggering any dependent futures.

Yields
  • (reason, *args) — to the task.
Returns

#then

def then(*args, &task) -> Future

Chains the task to be executed synchronously after it fulfills. Does not run the task if it rejects. It will resolve though, triggering any dependent futures.

Yields
  • (reason, *args) — to the task.
Returns

#value

def value(timeout = nil, timeout_value = nil) -> Object, nil, timeout_value

Method waits for the timeout duration and return the value of the future if fulfilled, timeout value in case of timeout and nil in case of rejection.

Parameters
  • timeout (Integer) — the maximum time in seconds to wait
  • timeout_value (Object) — a value returned by the method when it times out
Returns
  • (Object, nil, timeout_value) — the value of the Future when fulfilled, timeout_value on timeout, nil on rejection.

#wait!

def wait!(timeout = nil)

Method waits for the timeout duration and raise exception on rejection

Parameter
  • timeout (Integer) — the maximum time in seconds to wait