An open API service indexing awesome lists of open source software.

https://github.com/faruktoptas/mvvm-arch-sample

[WORK-IN-PROGRESS] Kotlin/Coroutines/Modular/Mvvm/LiveData/JUnit/Espresso
https://github.com/faruktoptas/mvvm-arch-sample

Last synced: about 1 month ago
JSON representation

[WORK-IN-PROGRESS] Kotlin/Coroutines/Modular/Mvvm/LiveData/JUnit/Espresso

Awesome Lists containing this project

README

          

# mvvm-arch-sample ![Android CI Action](https://github.com/faruktoptas/mvvm-arch-sample/workflows/build/badge.svg)
[WORK-IN-PROGRESS]

* Less boilerplate code
* Easy to read
* Testable (Unit and Instrumantation)
* Modularized by layer (Feature modules coming soon)

## Architecture
Screen Shot 2021-01-25 at 22 47 37

Screen Shot 2021-01-25 at 22 52 58

## What is used?
* JetPack ViewModel/LiveData
* Coroutines
* Koin
* DataBinding
* Unit Tests
* Instrumentation Tests
* Jacoco test coverage

## Samples

### Calling an api service (Errors are handled in base classes)
`MainViewModel.kt`
```kotlin
fun fetchItems() {
callService({ repo.getAlbums() }, {
albumsLive.postValue(it)
})
}
```

`MainRepositoryImpl.kt`
```kotlin
override suspend fun getAlbums() = apiWrapper { api.getAlbums() }}
```

### Calling an api service with overrided error case
```kotlin
fun fetchItems() {
callService({ repo.getAlbums() },
success = {
albumsLive.postValue(it)
},
failure = {
if (it is AError.Authorization) {
// clear token
} else {
postError(it)
}
}
)
}
```

## Testing
* All business logic is kept in ViewModels. Trying to keep ViewModel coverages near 100%.
* All network cases also tested with [ApiWrapperTest](https://github.com/faruktoptas/mvvm-arch-sample/blob/master/network/src/test/java/me/toptas/architecture/network/ApiWrapperTest.kt)

Screen Shot 2021-01-25 at 23 04 05

Screen Shot 2021-01-25 at 23 04 33

* Ui bound cases and view classes are tested with Espresso.

## Todos
* [ ] At least 2 screens with more interaction
* [ ] Navigation
* [ ] Feature modules
* [ ] Easy and readeble Espresso tests with [Robot pattern](https://medium.com/android-bits/espresso-robot-pattern-in-kotlin-fc820ce250f7)
* [x] Github actions