Skip to content

Commit

Permalink
Deprecate "onBackstackChange" in favor of recommended methods
Browse files Browse the repository at this point in the history
It can be easily misused.
  • Loading branch information
olshevski committed Aug 22, 2022
1 parent 5c604e9 commit c7c6791
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 0 additions & 2 deletions docs/nav-controller.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,3 @@ fun NavController<BottomNavigationDestination>.moveLastEntryToStart() {
## NavBackstack

You may access current backstack entries and the last [NavAction](/compose-navigation-reimagined/animations/#navaction) through `backstack` property of NavController. This property is backed up by [MutableState](https://developer.android.com/reference/kotlin/androidx/compose/runtime/MutableState) and any changes to it will notify composition.

If you want to listen for backstack changes outside of composition you may set `onBackstackChange` listener of NavController.
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ class NavController<T> internal constructor(
/**
* The current backstack. This property is backed up by [MutableState] and any changes to it
* will notify composition.
*
* If you want to listen for changes outside of composition, you may set [onBackstackChange]
* listener.
*/
val backstack get() = _backstack

Expand All @@ -104,6 +101,7 @@ class NavController<T> internal constructor(
* to [setNewBackstack].
*/
@Suppress("MemberVisibilityCanBePrivate")
@Deprecated("Use recommended Compose methods to listen for 'backstack' changes, e.g. snapshotFlow, derivedStateOf, etc.")
var onBackstackChange: ((backstack: NavBackstack<T>) -> Unit)? = null

/**
Expand Down

0 comments on commit c7c6791

Please sign in to comment.