Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scalio/command-based-architecture
Android Command Based Architecture for simple synchronization logic
https://github.com/scalio/command-based-architecture
android android-command architecture commandmanager kotlin-android
Last synced: about 1 month ago
JSON representation
Android Command Based Architecture for simple synchronization logic
- Host: GitHub
- URL: https://github.com/scalio/command-based-architecture
- Owner: scalio
- Created: 2020-03-23T03:31:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-05T22:17:41.000Z (about 1 year ago)
- Last Synced: 2023-10-05T23:24:30.414Z (about 1 year ago)
- Topics: android, android-command, architecture, commandmanager, kotlin-android
- Language: Kotlin
- Homepage:
- Size: 1.57 MB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Command Based Architecture](https://raw.githubusercontent.com/scalio/command-based-architecture/master/scalio-cba.svg?sanitize=true)
Command Based Architecture for Android
Process concurrent tasks on data sources
## Features
This is an Android Command Based Architecture for processing concurrent tasks (commands) on single or multiple data sources. This library supports the execution and synchronization of different tasks on multiple threads.
Key features in flow control:
1. Ability to control if a task should be executed or skipped based on current data (screen) state.
2. Ability to control if a task should be executed immediately or delayed based on current data (screen) state.
3. Ability to block/postpone other tasks during task execution.Key features in data change:
Each task has its own lifecycle:
1. After command was added to the queue - `onCommandWasAdded`
2. Immediately before command execution - `onExecuteStarting`
3. Immediately after successful execution - `onExecuteSuccess`
4. Immediately after failed execution - `onExecuteFail`
5. Final step of execution (called on any success or fail) - `onExecuteFinished`## Integration with Gradle
For coroutine implementation:
```
implementation 'io.scal:commandbasedarchitecture_coroutine:version'
```Please replace `version` with the latest version:
For RxJava implementation:
```
implementation 'io.scal:commandbasedarchitecture_rxjava:version'
```Please replace `version` with the latest version:
## How to use
Please find the full description in [the post](https://scal.io/blog/command-based-architecture).
Basic Setup:
1. Create an instance of CommandManager: `val commandManager: CommandManager by lazy { CommandManagerImpl(mutableScreenState, viewModelScope) }`
2. Use an existing or create a custom command (RefreshCommand, LoadNextCommand).
a. Implement execution strategy directly in the command (ExecutionStrategy class)
b. Implement data side effects during command lifecycle
3. Add command to execution queue by calling `commandManager.postCommand(yourCommand)`By default, the CommandManager uses `Dispatchers.Main` for execution, so you will need to switch to an appropriate Dispatcher if you require more complex logic.
## Customizations
TBD
## Example
![Example](https://raw.githubusercontent.com/scalio/command-based-architecture/master/resources/list_details_broadcast.gif)
#### Contact ####
Feel free to reach out to me.
Website: https://scal.io
LinkedIn: https://www.linkedin.com/company/scalio/
LinkedIn: https://www.linkedin.com/in/mig35/
Email: [email protected]
Email: [email protected]#### License ####
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 athttp://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.
## About us