https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
u

ursus

02/13/2020, 11:19 AM
How would you share little bits of logic across view models? Lets say function sized - no state
b

bohsen

02/13/2020, 11:45 AM
Using delegation and compose your
ViewModel
using this
Example:
Copy code
class SampleViewModel @Inject constructor(private val sampleInteractor: SampleInteractor) :
    ViewModel(), SampleDialogContract.Interactor by sampleInteractor
t

tschuchort

02/13/2020, 1:02 PM
Why not use functions then?
u

ursus

02/13/2020, 1:09 PM
where would you keep them?
d

Dariusz Rusin

02/14/2020, 11:42 AM
business logic is not the part of ViewModel. ViemModel should use domain services. Then that little bit of domain logic will stay same between all of ViewModels.
👍 2
I dont know who and when popularized that way of ViewModel understanding.
u

ursus

02/14/2020, 1:16 PM
Depends. too general to talk like that. Also one liner use cases are stupid
👏 1
t

tschuchort

02/14/2020, 4:39 PM
You can put the functions wherever. In the same file or in a different file
4 Views