MVI framework (Jetpack Compose, Coroutines, Dagger, Room, Router, SaveInstanceState, BackPressed)
Bloc is implementation of MVI pattern. Model (Store) contain business logic and emit State then View consume and render State. View emit Intent then Model consume and process Intent.
Single:
Hierarchy:
Model and View lives inside isolated unit called Component. Component are created by Assembler and initialized by InitialValue, have own lifecycle and scope for control coroutines. Communication between components do with Input and Output.
View coroutines work on Main dispatcher, Store and Component work on Default dispatcher, Services work on Default and IO dispatchers.
Store emit State reacted on Intent or Effect (ex getting data from database). Effect produce Intent. Store consume Intent and send it to Reducer for processing. As result Reducer generate new State and optional new Label. State used for notify View about changed.
Store and View can communicate with Component - Label used by Store, ViewEvents by View.
Router control which component active / deactive in current time in same level. It can be on screen level or any another (children router). Also Router participate in BackPressed logic.
Component - container and communicator for View and Store (Presenter in MVP arch), can be placed in separeted module
Input - pipe for communicate between Components (like Command)
Output - pipe for communicate between Components (like result event)
Description - configuration (contains constants and typed id for factory usage and ability of server rendering)
InitialValue - initial data for Component
Assembler - builder for Component, Store and View, supported binds, provice and factory
State - business data
Intent - View event to Model
Store - Model
View - ui logic
Reducer - Intent handler
Effect - Outer (ex. Service) event to Model
Label - Model event to Component
ViewEvent - View event to Component
Router - activator/deactivator of Component in same level
Interactor - command for business logic for use inside Reducer in complex case
Repository - data logic, convert data from service to business data, can be use directly in Store or in Interactor
Service - logic for receive / send data to outer environment
Schema:
Architecture:
Screenshots: