david.bilik
03/27/2020, 11:30 AMFlow
type? eg. im observing users from database, should i name it like
fun users() : Flow<List<User>>
or
fun observeUsers() : Flow<List<User>>
or
fun usersChanges() : Flow<List<User>>
or
fun getUsersStream() : Flow<List<User>>
?
There is a lot of options and im curious about the best practicessindrenm
03/27/2020, 6:14 PMgetUsersFlow
. Whether it's a well-used convention, I don't know.Marc Knaup
03/31/2020, 5:52 AMget
as it’s mostly redundant in Kotlin and rarely used.
userFlow()
or simply users()
would be fine imo 🙂sindrenm
03/31/2020, 10:04 AMMarc Knaup
03/31/2020, 10:13 AMsindrenm
03/31/2020, 10:24 AMOrhan Tozan
04/14/2020, 3:12 PMusers()
is what I would use, however, when there is some initial loading going like an initial overhead, I would call it observeUsers()
Orhan Tozan
04/14/2020, 3:13 PMusers()
should be the same, regardless how often I call it in a rowdavid.bilik
04/15/2020, 2:57 PMobserveUsers
in the past as well (with Rx) but now when I thought about it it does not make sense - the method is not observing anything, its returning me the observable. I am observing the result that the method will return me. I went with getUsersStream
approachMarc Knaup
04/20/2020, 11:44 AMFlow<User>
.
The plural “users” doesn’t make it much better imo as it’s easy to miss and not every word has a plural “s”, so consistency is difficult.
It could be either a “user list stream” or “user list state”.
I associate “stream” with something that keeps appending new data as it becomes available.
The Flow<List<User>>
more likely emits a completely new list every time that replaces the previous list. Hence “state”.