# OutcomeReceiverCompat

# OutcomeReceiverCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/os/OutcomeReceiverCompat.java+class:androidx.core.os.OutcomeReceiverCompat)  
Added in[1.16.0](https://developer.android.com/jetpack/androidx/releases/core#1.16.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/os/OutcomeReceiverCompat "View this page in Java")

<br />

```
interface OutcomeReceiverCompat<R, E : Throwable?>
```

<br />

*** ** * ** ***

Callback interface intended for use when an asynchronous operation may result in a failure. This interface may be used in cases where an asynchronous API may complete either with a value or with a[Throwable](https://developer.android.com/reference/java/lang/Throwable.html)that indicates an error.  

|                                             Parameters                                             |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<R>`                                                                                              | The type of the result that's being sent.                                                                                                                                                                                                                                                                                         |
| `<E : `[Throwable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html)`?>` | The type of the[Throwable](https://developer.android.com/reference/java/lang/Throwable.html)that contains more information about the error. This interface serves the same purpose as[android.os.OutcomeReceiver](https://developer.android.com/reference/android/os/OutcomeReceiver), but can be used on API versions before 31. |

## Summary

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onError](https://developer.android.com/reference/kotlin/androidx/core/os/OutcomeReceiverCompat#onError(E))`(error: E)` Called when the asynchronous operation fails.                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onResult](https://developer.android.com/reference/kotlin/androidx/core/os/OutcomeReceiverCompat#onResult(R))`(result: R!)` Called when the asynchronous operation succeeds and delivers a result value. |

## Public functions

### onError

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

```
fun onError(error: E): Unit
```

Called when the asynchronous operation fails. The mode of failure is indicated by the[Throwable](https://developer.android.com/reference/java/lang/Throwable.html)passed as an argument to this method.  

| Parameters |
|------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| `error: E` | A subclass of[Throwable](https://developer.android.com/reference/java/lang/Throwable.html)with more details about the error that occurred. |

### onResult

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

```
fun onResult(result: R!): Unit
```

Called when the asynchronous operation succeeds and delivers a result value.  

|  Parameters  |
|--------------|----------------------------------------------------|
| `result: R!` | The value delivered by the asynchronous operation. |