An open API service indexing awesome lists of open source software.

https://github.com/evant/compose-shown

Provides a callback for when a @Composable is shown to the user
https://github.com/evant/compose-shown

Last synced: about 1 year ago
JSON representation

Provides a callback for when a @Composable is shown to the user

Awesome Lists containing this project

README

          

# Compose-Shown

Provides a callback for when a `@Composable` is shown to the user. This can be useful for 'pageview'
analytics. It will re-fire when the activity is paused and resumed and _not_ re-fire on rotation.

## Usage

Simply add the `onShown` modifier to the composable you want to track.

```kotlin
Text("Hello", modifier = Modifier.onShown {
// fire pageview analytics event
})
```

You can also optionally pass keys, this will cause it to re-fire when the key changes. Say, for
example, you want to re-send when the search query changes.

```kotlin
SearchResults(modifier = Modifier.onShown(query) {
// fire when shown and when the query changes.
}, results)
```