Skip to content
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

provide androidx.lifecycle.compose.LocalLifecycleOwner in android target #434

Merged

Conversation

qdsfdhvh
Copy link
Contributor

@qdsfdhvh qdsfdhvh commented May 29, 2024

Currently, there are two LocalLifecycleOwner in cmp 1.6.10 (1.7.0+ will resolved it):

  • androidx.compose.ui.platform.LocalLifecycleOwner
  • androidx.lifecycle.compose.LocalLifecycleOwner

As per jetbrains's suggestion:

// androidx.lifecycle.compose.LocalLifecycleOwner.kt
Note: On Android, it works only with Compose UI 1.7.0-alpha05 or above.
 *  Please use [androidx.compose.ui.platform.LocalLifecycleOwner] on Compose 1.6.*

In the cmp code, wo can find that two LocalLifecycleOwner are the same without androidTarget.

skiko:

// TODO: Deprecate in 1.7.0
// @Deprecated(
//    "Moved to lifecycle-runtime-compose library in androidx.lifecycle.compose package.",
//    ReplaceWith("androidx.lifecycle.compose.LocalLifecycleOwner"),
// )
actual val LocalLifecycleOwner get() = androidx.lifecycle.compose.LocalLifecycleOwner

androidTarget:

actual val LocalLifecycleOwner = staticCompositionLocalOf<LifecycleOwner> {
    noLocalProvidedFor("LocalLifecycleOwner")
}

For now there are a lot of projects that are starting to use jetbrains-lifecycle-runtime-compose, I suggest we can provide androidx.lifecycle.compose.LocalLifecycleOwner in androidTarget first, and then provide the only androidx.lifecycle.compose.LocalLifecycleOwner in commonMain after cmp 1.7.0, this ensures that the user's normal use is guaranteed.

Copy link
Collaborator

@DevSrSouza DevSrSouza left a comment

Choose a reason for hiding this comment

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

Thanks!

@DevSrSouza DevSrSouza merged commit a7b5c12 into adrielcafe:main Jun 3, 2024
1 of 2 checks passed
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.

2 participants