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

Florian

10/24/2020, 4:56 PM
What the next step architecture-wise when methods in my repository become big and complex? Should I just keep it like this in the repository?
u

ursus

10/24/2020, 5:01 PM
a function?
😂 1
👏 2
f

Florian

10/24/2020, 5:19 PM
I was thinking about another layer
u

ursus

10/24/2020, 5:23 PM
why, first functions, then composition
o

Orhan Tozan

10/24/2020, 5:47 PM
On a seperate note, I would advise Flow usage in Repositories, LiveData only for UI.
u

ursus

10/24/2020, 6:09 PM
I'd advise to only use one async framework
☝️ 4
💯 1
o

Orhan Tozan

10/24/2020, 6:14 PM
Well, also using Flow in UI and throwing LiveData completely away might be n even better option indeed, but a more radical change in a codebase
👍 1
f

Florian

10/24/2020, 7:21 PM
yea I've heard that recommendation before but I've also heard other people say that this is a non-sensical guideline (to not put LiveData into repositories)
u

ursus

10/24/2020, 7:22 PM
arent live data always main thread?; also, why would anyone use live data in a worlds where rxjava and flow exists, do you hate yourself or what lol, its the same thing just with a subset of features
f

Florian

10/24/2020, 9:42 PM
I don't think Flow has the same lifecycle-awareness capabilities
u

ursus

10/24/2020, 9:43 PM
Have a scope which is active between activity.onStart/onStop, same thing
☝️ 4
💯 1
f

Florian

10/25/2020, 10:39 AM
it would do the same thing with more code
o

Orhan Tozan

10/25/2020, 1:12 PM
Flow does have the same lifecycle awara ness when you either use flow.asLiveData() or lifecyclescope.launch {flow.collect()}
u

ursus

10/25/2020, 2:14 PM
Live data its not less code, its just hidden. You can have scope created in some BaseActivity, then its same amount of lines (even if not, bringing in a framework to save 1 vs 3 lines..) + what he said, then built a lifecycleScope if youre into that
👍 1
f

Florian

10/25/2020, 3:11 PM
alright, I'll try it out, thank you 👍
n

Nathan Retta

10/29/2020, 11:26 PM
I have faced this issue and opted to abstract away some of this with use cases, which I have injected into the viewmodels. I also opted to use flow instead, where I've guaranteed that coroutine contexts are all appropriate
f

Florian

10/30/2020, 9:39 AM
@Nathan Retta Thank you very much!
Can I find an example of such usecases somewhere?
n

Nathan Retta

10/30/2020, 5:14 PM

https://www.youtube.com/watch?v=xch4aw7hNcY

I will share some of my code here as well for a basic use case
The use cases are meant to be light and easily consumed by the viewmodel. I have found that the abstraction layer is very useful when dealing with screens that have a lot going on, allowing the viewmodel to stay much lighter also. I tend to agree with the talk as presented, where the domain layer tells the story of how your app runs.
This app is a playground for ideas, any comments are welcome
👍 1
In this app, CityWeatherViewModel.kt has three use cases that you can use as an example
f

Florian

10/31/2020, 9:42 AM
thank you very much!
3 Views