ursus
02/18/2022, 1:27 PMvesp
02/18/2022, 5:14 PM_shtomar
03/03/2022, 3:27 AMursus
03/14/2022, 12:39 AMVishnu Haridas
03/19/2022, 7:50 PMgetNews()
class NewsRepository( localSource, remoteSource ){
val flow: Flow< Resource<NewsItem> > = // exposes the data, updates, and statuses
// Will you return a Resource<> here...
suspend fun getNews(): Resource<NewsItem> {
.
if(success) return Resource.Success(list)
else return Resource.Error(exception)
}
// ...Or return nothing and just emit the result?
suspend fun getNews(){
if(success) _flowData.emit( Resource.Success(list) )
else _flowData.emit( Resource.Error(exception) )
}
}
There can be other functions in the repository that will update the Flow and return nothing, for example:
suspend fun removeItem( newsId ){
// Remove item from the local copy
list.remove(newsId)
// Notify listeners
_flowData.emit( Result.success( list ) )
}
So my feeling is that I should make all the CRUD functions in the repository to return nothing but just update the Flow to avoid confusion.
Comments?Vikas Singh
03/28/2022, 12:05 PMNicolai
04/01/2022, 2:59 PMval observableActionsFilteredByPageId = Transformations.switchMap(filterPageId)
However, now I want to filter that data with different values. Meaning that for each page I would need multiple lists filtered by some other parameter... Something like this:
val contentView = observableActionsFilteredByPageId.map { actions ->
actions?.filter { it.actionType == "action_contentView" }
}
val notifications = observableActionsFilteredByPageId.map { actions ->
actions?.filter { it.actionType == "action_notification" }
}
Would this be a proper way to do it or am I using the APIs wrongly?
Thanks for your time!Ali
04/02/2022, 2:36 PMErik
04/07/2022, 12:38 PMVishnu Haridas
04/19/2022, 5:34 PMUtil
classes and putting shared logic in the domain layer as UseCases.
If that's the case, can I use object
s as a UseCase, for example:
// domain/GetTimeAgoUseCase.kt
object GetTimeAgoUseCase {
operator fun invoke(time: Long){
// return "a week"
}
}
..and use it in my UI layer like this:
class HomeViewModel: ViewModel(){
fun getTime(): String = GetTimeAgoUseCase(item.timestamp)
}
..or..
@Composable
fun ListItem(item){
Text("Posted ${ GetTimeAgoUseCase(item.timestamp) } ago")
}
Slackbot
05/05/2022, 4:04 PMAaron Waller
05/09/2022, 5:39 PMTariyel Islami
05/14/2022, 10:39 PMVikas Singh
05/20/2022, 4:56 PM_shtomar
05/23/2022, 7:36 PMK Merle
05/26/2022, 9:34 AMLokik Soni
06/17/2022, 6:10 PMMark Lurie
06/21/2022, 6:47 AMVikas Singh
06/23/2022, 8:36 AMfuad
06/25/2022, 12:38 AMLokik Soni
06/25/2022, 1:34 PMtakahirom
07/10/2022, 10:36 AMA feature module should have no dependencies on other feature modules.I was wondering what happens when a feature nests more than once. For example, if there is an "article screen" that has a "your article tab" and "daily article tab" in it, I thought that the feature module would want to depend on the feature module. In such a case, does nowinandroid assume that all tabs are implemented in the core module? If it is a simple screen, you can put it in the article feature module, but assume it is a complex and large function.
Layout structure
screen -> "article screen" -> "daily article tab"
module structure
app -> feature-article(contains "article screen") -> core-dailyarticle(contains "daily article tab")
-> core-yourarticle(contains "your article tab")
As I write this message, I am beginning to think that this is not a problem because it works fine.
https://github.com/android/nowinandroid/blob/main/docs/ModularizationLearningJourney.md#types-of-modules-in-now-in-androidVikas Singh
07/26/2022, 9:31 AMLilly
07/28/2022, 8:52 AMVikas Singh
08/05/2022, 6:47 AMLukasz Kalnik
08/05/2022, 12:56 PMModalBottomSheetLayout
where the contents is the main screen with a list of items, and the sheetContent
are item details (with different settings).
As the item details are quite complex, and don't influence the main screen, I would like to have them in a separate ViewModel. How can I pass the itemId
from the MainScreenViewModel
to the ItemDetailsViewModel
. I don't really fancy creating a shared ViewModel just to pass one value (which is anyway only temporary, as the ItemDetailsViewModel
will store itemId
as well to get the item data).aungbophyoe
08/24/2022, 4:40 PMLukasz Kalnik
08/25/2022, 4:54 PMdata
layer:
• ...Api
suffix for the Retrofit interface definitions (e.g. MoviesApi
)
• ...Repository
suffix for the class that abstracts away the Api
.
domain
layer:
• ...UseCase
for commonly used, well, use cases, they usually depend on Repository
(although often we skip this layer altogether)
presentation
layer:
• obviously ...ViewModel
here.
I'm asking because I have a ViewModel
which grew really large, so I would like to split it in multiple viewmodels. However they all share common view data to some degree, so have to depend on a single source of truth in the presentation layer. And I was wondering how to call such single source of truth in the presentation layer.Asad Mukhtar
08/27/2022, 4:20 PMYasser AKBBACH
08/29/2022, 12:11 PMuse cases
in clean architecture
with Android are just calling repositories
, why should we bother creating them? why not injecting repositories
in viewmodels
like we used to do?!Yasser AKBBACH
08/29/2022, 12:11 PMuse cases
in clean architecture
with Android are just calling repositories
, why should we bother creating them? why not injecting repositories
in viewmodels
like we used to do?!Javier
08/29/2022, 12:15 PMK Merle
08/29/2022, 12:36 PMYasser AKBBACH
08/29/2022, 12:39 PMK Merle
08/29/2022, 12:41 PMYasser AKBBACH
08/29/2022, 12:43 PMinput
and caring about output
and most of the work is being done in the repos
🤔 ?K Merle
08/29/2022, 12:44 PMYasser AKBBACH
08/29/2022, 12:45 PMrepository
Thanks 🙏Javier
08/29/2022, 12:47 PMK Merle
08/29/2022, 12:49 PMJavier
08/29/2022, 12:54 PMYasser AKBBACH
08/29/2022, 12:55 PMJavier
08/29/2022, 12:56 PMK Merle
08/29/2022, 12:59 PMcurioustechizen
08/29/2022, 2:58 PMJan Starczewski
08/30/2022, 7:21 AMFrancesc
08/31/2022, 2:42 AMK Merle
08/31/2022, 7:28 AMJavier
08/31/2022, 9:56 AMclass SomeUseCaseImpl : SomeUseCase {
operator fun invoke(id: Id): Flow<Some> {
val someDto = fetch()
someDto.saveInDatabase()
return database.getSomeAsFlow()
}
// do network request
private fun fetch()
// map to entity and save
fun SomeDto.saveInDatabase()
…
}
Arun Joseph
09/02/2022, 1:37 PMUseCase
boilerplate while maintaining layering.Pablichjenkov
10/07/2022, 5:44 AMDavide Giuseppe Farella
10/08/2022, 11:28 AM