Closed uvaysss closed 1 year ago
Hey hey, Backstack
generally exists within an Activity, so the only viable scope accessible from a Service is that of GlobalServices
.
For that, you'd need val globalServices = (context.applicationContext as YourApplication).globalServices
to get it, and then it's globalServices.get<T>()
.
So it's same idea as here: https://github.com/Zhuinden/simple-stack/blob/8d37157aee38ad54d3471b6e064ce9bb37ab86a1/samples/advanced-samples/extensions-example/src/main/java/com/zhuinden/simplestackextensionsample/app/MainActivity.kt#L29-L33
That makes sense.. Did miss that part about GlobalServices. Thank you for your quick response!
Maybe I've missed it somewhere in samples, but I cannot find any examples how to lookup an object from the Android Service.
The goal is to share data and observe it from a Repository'ish like object in a Fragment and Android Service.
I'm currently using a dagger singleton for this, but was thinking migrate to simple stack scoped services incrementally.