-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
Lifecycle KMP experimental support #423
Conversation
public val LocalNavigatorScreenLifecycleProvider: ProvidableCompositionLocal<NavigatorScreenLifecycleProvider?> = | ||
staticCompositionLocalOf { null } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for making it nullable and initialising it as null as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have moved the default implementation to the Navigator
module, when this is null, it will use the default implementation. The reason is for removing the android lifecycle API from the core module and move to the navigator, also avoid cycle dependencies
setupModuleForComposeMultiplatform(fullyMultiplatform = true) | ||
|
||
android { | ||
namespace = "cafe.adriel.voyager.kodein" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe?
namespace = "cafe.adriel.voyager.kodein" | |
namespace = "cafe.adriel.voyager.lifecycle.kmp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! forget to replace
compileOnly(compose.runtime) | ||
compileOnly(compose.runtimeSaveable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might lead to a warning like
A compileOnly dependency is used in the Kotlin/Native target 'ios....':
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a old approach that I don't know if is still required. In the past, if you not add compileOnly
to Compose KMP libraries, then, android only project would fail to use the library because it would not find the jetbrains android dependencies. I think this is fixed, but I not 100% sure without testing, for now, I will still keep this approach.
For the warning, we have a flag
https://github.com/adrielcafe/voyager/blob/main/gradle.properties#L12-L19
// when the Application goes to background, perform save | ||
performSave(outState) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any special reason why not saving it for onPause
lifecycle as well?
Usage:
In the Screen, just use plain Lifecycle ViewModel Compose
viewModel
callback or any third party DI that already supports lifecycle kmp.This PR also updates Compose KMP to 1.6.10