Hi! Is it good idea to return `Flow` from all meth...
# android-architecture
n
Hi! Is it good idea to return
Flow
from all methods in
Repository
interface (if they return something), instead of simple suspend functions with direct return type? Even if there is no plans to implement some kind of caching functionality in the near future. Coming from RxJava perspective where this is usually the case (all methods are either Single, Observable etc.) I’m still unsure if this is beneficial in case if repository someday will need to expose stream of data instead of one shot return function. Any best practice advice?
s
If it returns 1 thing then make it
suspend
and return the thing directly.
plus one 7
💯 1
1
h
Agree with Stylianos, try to keep the code as simple as possible and only use flow when it really gives a benefit
n
Thank you
s
... someday will need ...
Don't over engineer 😀 If you ain't gonna need it, don't design/code for it. When (IF!) the time comes when a flow is needed, then that bridge will be crossed then.