Hello, im trying to share an object that will live...
# compose-destinations
r
Hello, im trying to share an object that will live within 2 screen destinations, any clue how i can achieve that? i was trying to use dependenciesContainerBuilder like
Copy code
dependenciesContainerBuilder = {
navGraph(SomeNavGraph){
dependency(SomeObject())
}
and then im trying to inject this by
Copy code
ScreenA(
...
someObject: SomeObject
)

ScreenB(
...
someObject: SomeObject
)
where SomeNavGraph contains 2 destinations, im using Koin in the project object is getting injected but these are 2 different objects in both of the screens both screens belong to nested SomeNavGraph is this possible for non viewmodel objects?
m
you can share viewmodel instance if both routes falls under same activity
r
thats single activity app and i think i should bind this to screenA lifecycle 🤔
m
or make the object singleton
r
well i did end up with a helper class for now, but thatll be great to know how to scope things 😕
m
https://developer.android.com/guide/fragments/communicate#viewmodel check how data is being shared in two fragments so you can adopt similar approach for two destinations using viewmodel