# ViewfinderInitScope

Artifact: [androidx.camera.viewfinder:viewfinder-compose](https://developer.android.com/jetpack/androidx/releases/camera-viewfinder) [View Source](https://cs.android.com/search?q=file:androidx/camera/viewfinder/compose/Viewfinder.kt+class:androidx.camera.viewfinder.compose.ViewfinderInitScope) Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera-viewfinder#1.5.0)


```
interface ViewfinderInitScope
```

<br />

*** ** * ** ***

A scoped environment provided when a `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/compose/Viewfinder.composable#Viewfinder(androidx.camera.viewfinder.core.ViewfinderSurfaceRequest,androidx.compose.ui.Modifier,androidx.camera.viewfinder.core.TransformationInfo,androidx.camera.viewfinder.compose.MutableCoordinateTransformer,androidx.compose.ui.Alignment,androidx.compose.ui.layout.ContentScale,kotlin.Function1)` is first initialized.

The environment can be used to register a lambda to invoke when a new `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/ViewfinderSurfaceSessionScope` is available.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/compose/ViewfinderInitScope#onSurfaceSession(kotlin.coroutines.SuspendFunction1)(block: suspend https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/ViewfinderSurfaceSessionScope.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Registers a callback to be invoked when a new `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/ViewfinderSurfaceSessionScope` is created. |

## Public functions

### onSurfaceSession

Added in [1.5.0](https://developer.android.com/jetpack/androidx/releases/camera-viewfinder#1.5.0)

```
fun onSurfaceSession(block: suspend ViewfinderSurfaceSessionScope.() -> Unit): Unit
```

Registers a callback to be invoked when a new `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/ViewfinderSurfaceSessionScope` is created.

The provided callback will be invoked each time a new `ViewfinderSurfaceSessionScope` is available. If a new `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/core/ViewfinderSurfaceSessionScope` is available, the previous one will be cancelled before `https://developer.android.com/reference/kotlin/androidx/camera/viewfinder/compose/ViewfinderInitScope#onSurfaceSession(kotlin.coroutines.SuspendFunction1)` is invoked with the new one.

The provided callback will always be invoked from the main thread.