# ViewModelStoreProvider.ReferenceToken

Artifact: [androidx.lifecycle:lifecycle-viewmodel-savedstate](https://developer.android.com/jetpack/androidx/releases/lifecycle) [View Source](https://cs.android.com/search?q=file:androidx/lifecycle/viewmodel/ViewModelStoreProvider.kt+class:androidx.lifecycle.viewmodel.ViewModelStoreProvider.ReferenceToken) Added in [2.11.0](https://developer.android.com/jetpack/androidx/releases/lifecycle#2.11.0)

*** ** * ** ***

Common/AllAndroid/JVM
- Cmn

  ```
  fun interface ViewModelStoreProvider.ReferenceToken : AutoCloseable
  ```

*** ** * ** ***

Represents an active hold on a specific `https://developer.android.com/reference/kotlin/androidx/lifecycle/ViewModelStore`.

As long as this token remains active, the underlying ViewModels will survive calls to `https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/ViewModelStoreProvider#clearKey(kotlin.Any)` or `https://developer.android.com/reference/kotlin/androidx/lifecycle/viewmodel/ViewModelStoreProvider#clearAllKeys()`. This allows them to safely outlive their immediate UI (e.g., during exit animations).

Calling `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-auto-closeable/close.html` releases this hold and decrements the reference count for the store. If the store has been marked for removal and this was the last active reference, the store will be immediately cleared.

## Summary

### Inherited functions

From [kotlin.AutoCloseable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-auto-closeable/index.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-auto-closeable/close.html()` Cmn