# CallbackToFutureAdapter.Resolver

Artifact: [androidx.concurrent:concurrent-futures](https://developer.android.com/jetpack/androidx/releases/concurrent) [View Source](https://cs.android.com/search?q=file:androidx/concurrent/futures/CallbackToFutureAdapter.java+class:androidx.concurrent.futures.CallbackToFutureAdapter.Resolver) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/concurrent#1.0.0)

*** ** * ** ***


```
public interface CallbackToFutureAdapter.Resolver<T>
```

<br />

*** ** * ** ***

This interface should be implemented by the object passed into `https://developer.android.com/reference/androidx/concurrent/futures/CallbackToFutureAdapter#getFuture(androidx.concurrent.futures.CallbackToFutureAdapter.Resolver<T>)`.

Implementations are responsible to resolve passed `https://developer.android.com/reference/androidx/concurrent/futures/CallbackToFutureAdapter.Completer` object to success or failure inline or in the response to some other callback.

This interface creates a logical scope for the code that resolves a future returned from `https://developer.android.com/reference/androidx/concurrent/futures/CallbackToFutureAdapter#getFuture(androidx.concurrent.futures.CallbackToFutureAdapter.Resolver<T>)` and separates it from outer scope that works with that future as adding listeners etc. This separation allows us to detect situations when the returned future isn't done, but the completer object was garbage collected, and fail the future appropriately instead of keeping the future and its listeners chain forever.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/concurrent/futures/CallbackToFutureAdapter.Resolver#attachCompleter(androidx.concurrent.futures.CallbackToFutureAdapter.Completer<T>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/concurrent/futures/CallbackToFutureAdapter.Completer<T> completer)` Create your callback object and start whatever operations are required to trigger it here. |

## Public methods

### attachCompleter

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/concurrent#1.0.0)

```
abstract @Nullable Object attachCompleter(@NonNull CallbackToFutureAdapter.Completer<T> completer)
```

Create your callback object and start whatever operations are required to trigger it here.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/concurrent/futures/CallbackToFutureAdapter.Completer<T> completer` | Call one of the set methods on this object to complete the returned Future. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` | an object to use as the human-readable description of what is expected to complete this future. In error cases, its toString() will be included in the message. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/Exception.html` |   |