Hey Andriy,
Why do you need that? I'd suggest injecting
repositories
to share state OR inject
use cases
for sharing logic
a
amatkivskiy
01/03/2019, 4:34 PM
@kzotin I’ve created a simple diagram to show what I need.
amatkivskiy
01/03/2019, 4:37 PM
Sorry for the quality, if this is not usable I can link draw.io diagram.
amatkivskiy
01/03/2019, 4:39 PM
@kzotin I was looking for the way to handle such cases (was hoping to avoid ugly Google approach with interfaces passed through activity and fragments )
k
kzotin
01/10/2019, 8:52 PM
Would suggest to use reactive data types (LiveData or Observable) via shared repository.
SelectProductViewModel
sets value in
ProductRepository
,
BasketViewModel
observes changes
a
amatkivskiy
01/12/2019, 4:55 AM
good point
amatkivskiy
01/22/2019, 3:50 AM
@kzotin What if I pass an interface to the
SelectProductViewModel
which is implemented by
BasketViewModel
? The only thing that should be taken into account is lifecycles of the viewmodels otherwise we can face a memory leak.