Skip to content

Conversation

@terrakok
Copy link
Member

@terrakok terrakok commented Oct 1, 2025

It enables a support of the Nav3 library on Desktop, Web and iOS.

n3.mp4

Fixes: CMP-8937 Adapt changes in NavigationEventHandler

Testing

  • Manually tested in a demo app
  • This should be tested by QA

Release Notes

Features - Navigation

  • Basic support of the navigation3 library.


LaunchedEffect(enabled) {
if (enabled) {
dispatcher.transitionState

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can listen to the state passed to NavigationBackHandler down below, which is local to this handler, instead of listening to dispatcher.transitionState. As there may be several handlers in a composition and this handler may not be the active one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, I'll try tomorrow

mutableStateOf(null)
}

fun getActiveProgressChannel(): Channel<BackEventCompat> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a TIL question. What is the benefit of using Channel instead of Flow these days? Is it for performance?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a lighter low-level abstraction.

Copy link

@marcellogalhardo marcellogalhardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@terrakok terrakok merged commit 0255eff into jb-main Oct 2, 2025
10 checks passed
@terrakok terrakok deleted the cmp-8937-new branch October 2, 2025 10:50
getActiveProgressChannel().send(event)
}
val transitionState = navEventState.transitionState
if (transitionState is NavigationEventTransitionState.InProgress) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it get to run when the transition state turns from Idle to InProgress again after a composition?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nvm, it does.

}
val transitionState = navEventState.transitionState
if (transitionState is NavigationEventTransitionState.InProgress) {
LaunchedEffect(transitionState) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the coroutine relaunch after every transitionState change? For example, if we see:

1. Idle
2. InProgress(eventA)
3. InProgress(eventB)
4. InProgress(eventC)
5. Idle

Does it launch 5 times?

@Composable
actual fun PredictiveBackHandler(
enabled: Boolean,
onBack: suspend (progress: Flow<BackEventCompat>) -> Unit

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that onBack is still called after cancellation. Not sure if it's our fault. For example:

PredictiveBackHandler(true) { progress ->
    Log.d("gyz", "start")
    try {
        progress.collect { Log.d("gyz", it.toString()) }
        Log.d("gyz", "finish")
    } catch(e: Exception) {
        Log.d("gyz", "cancelled")
    }
}

And after it prints "cancelled", it then prints another "start" and back event.

@jadlr
Copy link

jadlr commented Oct 8, 2025

Manually tested in a demo app

I'd like to try nav3 in my little cmp side project. Is that demo app public by any chance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants