-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add onComplete param to popWhile function in RouterExt.kt #104
feat: add onComplete param to popWhile function in RouterExt.kt #104
Conversation
decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/RouterExt.kt
Outdated
Show resolved
Hide resolved
Ahh, and could you please run |
Thank you for the suggestions, I've updated my branch |
Sorry, the sample master-detail doesn't compile. It's better to also allow the most common use case without Perhaps we need two variants - the existing one as it is now, and the new one with all required arguments:
Do you want to update? Or alternatively I can do it in your branch. If you will update, please don't forget to rerun |
So the existing function will delegate to the new one, similar to Decompose/decompose/src/commonMain/kotlin/com/arkivanov/decompose/router/RouterExt.kt Line 9 in 96d08a3
|
I will do it as soon as I get to my PC. |
Thanks for your contributions!
I should have noticed this at the very beginning. :-) |
How about we just swap the parameters to be inline fun <C : Any> Router<C, *>.popWhile(
crossinline onComplete: (isSuccess: Boolean) -> Unit = {},
crossinline predicate: (C) -> Boolean
) {
navigate(
transformer = { stack -> stack.dropLastWhile(predicate) },
onComplete = { newStack, oldStack -> onComplete(newStack.size < oldStack.size) }
)
} This way the API would be backwards compatible. Although having the first parameter being optional is not always best practice, we could prevent having to overload |
There are a few points:
|
There is a build error:
Could you please run |
Thanks for the contribution! |
Closes #98