Comments (6)
Please check ProductsListViewModel
. That _idsQuery
is your username/password from UI which you have set it by:
fun getProductsList() {
loading(true)
_idsQuery.value = ""
}
Then your usecase receive that emit here: getBeersListUseCase(GetBeersListParams(ids = it))
Send it to your repository:
override fun invoke(params: GetBeersListParams): Listing<RecyclerItem> =
productsRepository.getBeersById(params.ids)
and it sends to the API.
And here you can handle success/error of login:
val ldBeersList: LiveData<PagedList<RecyclerItem>> = switchMap(result) {
loading(false)
it.data
}
private val errorResult: LiveData<Throwable> = switchMap(result) {
loading(false)
it.error
}
from mvvmtemplate.
from mvvmtemplate.
You said:
data from view to data layer"
Anyway, by Mappers, you could convert your data objects to each other. Create your custom Mapper.
from mvvmtemplate.
from mvvmtemplate.
from mvvmtemplate.
@droidwithme Instead of injecting API into *RemoteDataSource and doing mapping there and injecting *RemoteDataSource into *RepositoryImpl,
Do this instead:
Inject API into *RepositoryImpl and do the mapping there. Like:
class BlahRepositoryImpl @Inject constructor(
private val blahApi: BlahApi
) : BlahRepository {
override fun getItems(): Single<RecyclerItem> =
blahApi.getItems().map { it.toDomain() }
}
I'd suggest you read this article again: https://proandroiddev.com/mvvm-with-clean-architecture-c2c021e05c89
from mvvmtemplate.
Related Issues (14)
- Are you planning to add persistence feature? HOT 1
- How to include a foreground location service with this architecture?
- How would the ProductsPagingSourceByCoroutine looks like for normal api call that doesn't support paging HOT 3
- What is the best way to implement a use case that doesn't have any params? HOT 1
- [BUG]: JAVA_HOME is not set. HOT 5
- I am unable to inject main activity in base fragment HOT 1
- [BUG]: Title goes here HOT 1
- [BUG]: Title goes here HOT 1
- [BUG]: Showing the loading animation on the loaded list
- Could not clone: Drjacky/MVVMTemplate is not a template repository. HOT 2
- Memory leak HOT 3
- Empty screen instead of no internet connection view HOT 3
- [BUG]: Showing no internet screen after rotation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mvvmtemplate.