A powerful android rx-active Architecture
The app is a sample project that shows how to implement the RxAndroidArchitecture into your Android app.
It is a layer-based architecture that allows a real disentangle of the UI components from the business logic.
The main components are:
- UI
- Coordinator Manager and Coordinators
- EventDispatcher
- UseCase
- Repository
The UI layer of the architecture comprises activities, fragments and views. The role of an activity is to coordinate the navigations by managing widgets and screens.
Fragments are instead the components that request and use the coordinators requesting them to the Coordinator Manager. Each fragment can use multiple coordinators and one coodinators can be used by several fragments. The communications among them take place by means of an EventDispatcher.
A Coordinator can be thought as an advanced version of the Presenter of the MVP model. Compared to it, the coordinator offers the following advantages:
- reference decoupling from the views
- allows for multi-layers inner structure
- TDD oriented
The Coordinator - UI communication is based on an Events exchange mechanism and the events are carried by an EventBus (here implemented by the EventDispatcher object).
A single coordinator can coordinate multiple business logic activities that are executed by objects of type UseCase.
The Coordinator object is heavly based on Reactive Programming and it associates a Subscriber to the UseCases. A Subscriber is an object that is able to handle results from UseCases. Moreover the a Coordinator handles answers from subscribers and is able to propagate them to the views by means of the mechanism explaind before.
The CoordinatorManager handles the initializations of the coordinators. It stores them into a map. In such a paradigm the coordinators are treated as singletons.
The EventDispatcher is an EventBus made of two RxBuses: one for the UI thread and another one for asyncronous operations (network calls, CRUD oprations, etc).
The Event annotation identifies the classes that defines the type of object that will be sent through the EventDispatcher.post(Object o) method.
dependencies {
compile 'com.baseandroid:baseandroid-navigation:0.0.6'
compile 'com.baseandroid:baseandroid-core:0.0.6'
compile 'com.baseandroid:baseandroid-busadapter:0.0.6'
compile 'com.baseandroid:baseandroid-coordinatoradapter:0.0.6'
compile 'com.baseandroid:baseandroid-repositoryadapter:0.0.6'
compile 'com.baseandroid:baseandroid-rxeventdispatcher:0.0.6'
compile 'com.baseandroid:baseandroid-rxcoordinator:0.0.6'
compile 'com.baseandroid:baseandroid-rxrepository:0.0.6'
}
Copyright (C) 2017 Sysdata S.p.A.
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.