# WebViewOutcomeReceiver

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

*** ** * ** ***


```
interface WebViewOutcomeReceiver<T, E : Throwable?>
```

<br />

Known direct subclasses [OutcomeReceiverCompat](https://developer.android.com/reference/kotlin/androidx/webkit/OutcomeReceiverCompat)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/webkit/OutcomeReceiverCompat` | **This interface is deprecated.** The `OutcomeReceiverCompat` name clashes with the same class in ` androidx.core`, so the webkit library version was renamed to avoid confusion. <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 `https://developer.android.com/reference/java/lang/Throwable.html` that indicates an 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. It is also identical to [androidx.core.os.OutcomeReceiverCompat](https://developer.android.com/reference/androidx/core/os/OutcomeReceiverCompat), but the `androidx.webkit` library maintains a separate copy to be able to remain at `compileSdk = 33`, which would not be possible with a dependency on `
androidx.core:core:1.16.0`, which uses `compileSdk = 35`.

| Parameters |
|---|---|
| `<T>` | The type of the result that's being sent. |
| `<E : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html?>` | The type of the `https://developer.android.com/reference/java/lang/Throwable.html` that contains more information about the error. |

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewOutcomeReceiver#onError(E)(error: E)` Called when the asynchronous operation fails. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/webkit/WebViewOutcomeReceiver#onResult(T)(result: T!)` 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/webkit#1.16.0)

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

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

| Parameters |
|---|---|
| `error: E` | A subclass of `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/webkit#1.16.0)

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

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

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