-
Notifications
You must be signed in to change notification settings - Fork 74
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
Screen can get the service from wrong scope during back animation #274
Comments
Curiously, this is the one thing I've been wondering about ever since creating What I do know is that this is also why I added In fact, to my surprise, this is what the changelog says:
So apparently I knew about this 4.5 years ago, but somehow it never came up in my usecases. Knowing that, the following works: val backstack = LocalBackstack.current
val key = LocalComposeKey.current as FirstKey
val eventHandler = rememberService<ActionHandler>()
val commonSharedService = remember {
backstack.lookupFromScope<CommonSharedService>(
key.scopeTag,
CommonSharedService::class.java.name
)
} Not exactly optimal, there's clearly no I'm not sure what to do about it as this is happening according to |
So, something like this would be a solution? matejdro/simple-stack-compose-integration@fffbc52 Maybe documentation should emphasize |
I've been using |
I added a This generally hasn't come up as I usually have 1 specific service type for screen so that you can utilize lookup across screens via implicit parents. |
I think this is "resolved" by Zhuinden/simple-stack-extensions@9c7d00f and Zhuinden/simple-stack-extensions@5471b83 + reusing service name is not technically "disallowed", disallowing it would be a breaking change. It could be hypothetically possible to add a "strict mode" where this case throws but not sure if that really helps. |
Yes, this has been resolved. Sorry, I forgot to close it. |
With the following version of the
example-simple
: https://github.com/matejdro/simple-stack-compose-integration/tree/service-reuse-issueCommonSharedService
(note displayed hashcode)CommonSharedService
(displayed hashcode is different from the first)I feel like this behavior might not be intended? If each screen has its own scope, then it should receive service from their own scope first, right? I realize that simple stack always takes the latest available scope first, but this might not be the best in all cases.
Not sure if this is a bug, just want to start a discussion regarding this issue. What is the best way to workaround this?
The text was updated successfully, but these errors were encountered: