# SuspendingAppFunction

Artifact: [androidx.appfunctions:appfunctions](https://developer.android.com/jetpack/androidx/releases/appfunctions) [View Source](https://cs.android.com/search?q=file:androidx/appfunctions/SuspendingAppFunction.kt+class:androidx.appfunctions.SuspendingAppFunction) Added in [1.0.0-rc01](https://developer.android.com/jetpack/androidx/releases/appfunctions#1.0.0-rc01)

*** ** * ** ***


```
@ExperimentalAppFunctionsApi
public fun interface SuspendingAppFunction
```

<br />

*** ** * ** ***

An implementation of an app function that supports suspend execution.

This interface is expected as part of `https://developer.android.com/reference/androidx/appfunctions/HandleAppFunctionRequest`.

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse` | `https://developer.android.com/reference/androidx/appfunctions/SuspendingAppFunction#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest request)` Called when the app function is invoked using `https://developer.android.com/reference/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)`. |

## Public methods

### executeAppFunction

```
abstract @NonNull ExecuteAppFunctionResponse executeAppFunction(@NonNull ExecuteAppFunctionRequest request)
```

Called when the app function is invoked using `https://developer.android.com/reference/androidx/appfunctions/AppFunctionManager#executeAppFunction(androidx.appfunctions.ExecuteAppFunctionRequest)`.

- If this method completes successfully, the returned `https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse` is delivered to the caller.

- If this method throws an `https://developer.android.com/reference/androidx/appfunctions/AppFunctionException`, it is caught and returned to the caller as an `https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse.Error` wrapping the exception.

- If execution is cancelled via a platform cancellation signal, an `https://developer.android.com/reference/androidx/appfunctions/AppFunctionCancelledException` error response is delivered to the caller.

- If this method throws any other uncaught exception (such as `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-runtime-exception/index.html`), an `https://developer.android.com/reference/androidx/appfunctions/AppFunctionAppUnknownException` error response is reported to the caller, and the exception is rethrown to unregister the app function and terminate its handling coroutine scope.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionRequest request` | The request details. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/appfunctions/ExecuteAppFunctionResponse` | The execution response result. |