-
Notifications
You must be signed in to change notification settings - Fork 89
Enable circuit-retained without composition local manual setup #1670
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
Comments
I think this would be possible. Would need to pull something together to setup a multi-platform continuity instance as a default. Wouldn't necessarily want to do that setup at each retained use though 🤔 Think at a minimum we should add a Curious whats the limitation around setting up a composition local, or adding a |
I think managing the backstack might be challenging if only one composition local is provided. It might be beneficial if we could use ViewModels and Lifecycles from Compose Multiplatform instead of relying on the current composition local to achieve smooth integration, assuming they do not already exist. However, this approach may be very complex. |
Ahh so specifically an integration with Jetpack/Compose Navigation where the view model store is setup per route. We're doing something similar in Could be doable, let folks provide a default instead of the |
This now works entirely via local |
I think you can use |
Can you elaborate more on how that would look? Circuit-retained already uses a backing viewmodel in android |
Well, as you know, this is my library, and it just uses |
Yes but I don't see androidx navigation used in that file? It appears to have its own backing viewmodel and a new one is instantiated for each |
I think we don't need to add a dependency on the navigation library. The navigation library provides a composition local, which we can use. |
The title is requesting rememberRetained support without use of a composition local but that seems to require a composition local? Or rather, it seems like the request is to just use a different composition local ( |
To be clear, I think we needed to be done with different CompositionLocal implementations. What I wanted was an easy setup for most Compose users. That said, I also believe it might be challenging to implement this in |
Could you elaborate on why you feel it's difficult to set up a local |
It's preferable to have the ability to manually provide the RetainedStateRegistry to the ViewModel, rather than not having this option at all. I'm uncertain whether we can implement Regarding the creation of a new ViewModel instance for each |
There is an overload of
This is functionally what the circuit implementation does :). The viewmodel and the impl it delegates to. |
@takahirom given that, do you think I can close this? |
Since the original issue title references "Sample or Integration Implementation using circuit-retained with Jetpack Navigation (or JetBrains Compose Multiplatform Navigation)", I'd be interested in seeing a sample implementation or test case demonstrating rememberRetained with Navigation components. However, I'm currently uncertain whether this integration is feasible. If you prefer to close this issue, that's acceptable - this request primarily reflects my personal interest rather than an urgent technical requirement. We can always create a new issue if specific implementation challenges emerge later. Please feel free to proceed with closing this. |
SavedState (called Bundle in Android) now supports kotlinx.serialization in the alpha version, so making it easier to use rememberSaveable. val state = rememberSaveable(
saver = Saver(
save = { encodeToSavedState(it) },
restore = { decodeFromSavedState(it) }
)
) { UiState(emptyList(), emptyList()) }
@Serializable
data class UiState(
val cats: List<Cat>,
val dogs: List<Dog>
) I think rememberRetained will no longer be necessary in the future. |
I think that claim reveals a lack of understanding in what circuit-retained is for :). Marshaling and unmarshaling every time isn't free, nor is it possible or practical to make everything that goes into circuit-retained today serializable. For example - coroutine scopes. I am going to close this for now as it's no longer an issue/FR and really just a question. Please feel free to post in the Q&A section of the discussions panel of the repo if you want to pursue this. My conclusion from the above conversation is that circuit-retained supports everything you need, that fork seems to just interop to |
Thank you for developing this fantastic library. I’d like to use circuit-retained with Jetpack Navigation (or JetBrains Compose Multiplatform Navigation) without needing to set up a composition local for rememberRetained{}. Is this possible, or could you provide guidance on how to achieve this?
The text was updated successfully, but these errors were encountered: