Promise (Grails 3.2.7)
Date: 2017-03-06

Package: grails.async

## [Groovy] Interface Promise<T>

- Encapsulates the notion of a Promise, a Future-like interface designed to easy integration of asynchronous functions

  Authors:
    Graeme Rocher
  Since:
    2.3

- - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `Promise<T>` | `accept(T value)` Assigns a value to an unfulfilled promise
    `Promise<T>` | `onComplete(groovy.lang.Closure callable)` Execute the given closure when the promise completes
    `Promise<T>` | `onError(groovy.lang.Closure callable)` Execute the given closure when an error occurs
    `Promise<T>` | `then(groovy.lang.Closure callable)` Same as #onComplete

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `interface java.util.concurrent.Future` | `java.util.concurrent.Future#isDone(), java.util.concurrent.Future#get(), java.util.concurrent.Future#get(long, java.util.concurrent.TimeUnit), java.util.concurrent.Future#cancel(boolean), java.util.concurrent.Future#isCancelled()`
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Method Detail

    - #### Promise<T> accept(T value)

      Assigns a value to an unfulfilled promise

      Parameters:
        `value` - The value

    - #### Promise<T> onComplete(groovy.lang.Closure callable)

      Execute the given closure when the promise completes

      Parameters:
        callable
      Returns:
        The Promise

    - #### Promise<T> onError(groovy.lang.Closure callable)

      Execute the given closure when an error occurs

      Parameters:
        callable
      Returns:
        The Promise

    - #### Promise<T> then(groovy.lang.Closure callable)

      Same as #onComplete