Awesome Open Source
Awesome Open Source

Platform Build Status

Coroutines Flows - Modularised 🚀

banner

Table of Contents

Demo

Introduction

The purpose of this project is to consolidate some of the learned insights throughout the years about the Clean Architecture principles and reflect those lesson on Android, taking advantage of the Kotlin programming language features too. This project summarises some of the general use cases and needs that could be demanded on a production project using: Functional Programming,MVVM setup, Coroutines, Kotlin Flows and LiveData (I've kept a branch using RxJava too).

structure

On Going Work

🔛 Paging 2 library integration 🔛 UI Update 🔜 Jetpack Compose

Modules

  • app - The application module with access to all the application
  • data - Android module that can only access domain module
  • data-api - Android module that can only access data module
  • domain - Kotlin module that cannot access any other module
  • presentation - Android module that can only access domain module
  • navigation - Android jetpack navigation abstraction (it contains the navigation config file) cannot access any other module

And two extra modules:

  • core - Base classes module (factories, events, etc.) that cannot access any other module
  • core-android-test - Tests classes module (rules, date builders,etc.) that cannot access any other module

Testing

Unit Testing

There are some highlights:

  • Every layer in the architecture has been tested with its mapper|transformer|provider.
  • Mockito has been used for mocking|stubbing.
  • Given|When|Then steps have been followed, in order to give a more structured overview.

UI Testing

I opted for a dynamic test configuration, so it's possible to inject different configurations as peer need. Find more info in my post right here 👉 Medium Post

  • In order to mock the responses and use them for instrumentation testing, I've used MockWebServer.
  • In order to give a concise and clean face of the Espresso tests, I've applied Robot Pattern.

Libraries Used

  • Coroutines Library support for Kotlin coroutines.
  • Flows for asynchronous data streams.
  • LiveData for reactive style programming (from VM to UI).
  • Navigation for in-app navigation.
  • Dagger2 for dependency injection.
  • Retrofit for REST api communication.
  • Timber for logging.
  • Espresso for UI tests.
  • Mockito-Kotlin for mocking in tests.
  • MockWebServer for Instrumentation tests.
  • AndroidX Test Library for providing JUnit4 and functions as launchActivity in UI tests
  • Picasso Image downloading and caching library
  • JodaTime Date library that lets manage more extensively and easily dates
  • BottomSheet Library that contains a bottom sheet view with animations (expand/collapse)
  • SolidAdapter Library that provides a SolidAdapter implementation, instead of RecyclerView.Adapter

License

Copyright 2021 Fernando Prieto Moyano

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Kotlin (59,535
Android (40,851
Mvvm (2,571
Retrofit2 (1,862
Clean Architecture (1,756
Coroutines (1,390
Dagger2 (1,231
Flow (1,128
Livedata (928
Clean Code (711
Mvvm Android (521
Solid (489
Android Architecture (483
Espresso (268
Coroutines Android (228
Junit4 (184
Related Projects