Clean Architecture + Redux + Android

Have been learning a few new tricks in mobile architecure on the native side.

Applying the redux pattern to code outside of react has been interesting.

Jetpack Compose

Android compose is a modern declarative toolkit for building user interfaces.

Compose works with functions and is very much in-line with SwiftUI and React Native.

Inputs to compose functions become important in determining whether the UI should re-compose.

You can remember values for re-composing, but the only state is the function parameters.

Less code, simpler, easier to maintain (reminds me of a functional more efficient Java Mobile Edition)

Kotlin Flow

Kotlin flow borrows from Reactive extensions and Golang channels to allow observable streams that produce and consume state.

This works well with compose in that state produced from a kotlin flow can trigger a compose function to recompose.

  val state = viewModel.stateFlow()

Clean Architecture

Clean architecture from uncle bob has been around a while and defines principles for low complexity maintable code.

The principles are known as the SOLID acronym. They were somewhat self-intuitive to me, but its nice there is a formal definition.

The book also describes layering a code base (typically data, domain and ui) to promote the use of these principles.

For example when sending data from the data layer to the ui layer, it becomes necessary to define an interface for it which is the Dependency inversion principle.


The overview says “redux is a pattern for managing application state using events”.

Keeping state immutable is important when complexity grows.

Thinking of clean architecture, the redux pattern follows the Single Responsibility principle. It is perhaps a bit more cohesive than similar architectures (MVI).

Store and Reducers

Modifying immutable state is done through reducers to return a new state.

The store publishes and subscribes to events and maintains state from reducers.


Actions are events that hook into the application, such as user interface, and dispatched to the store.

onClick={ dispatch(ViewAction.ButtonClicked) }

Middleware or Effects

The store sometimes has middleware that performs actions on events that do not return a new state.

In the web world, this is middleware, in the mobile world, this seems to be called “effects” (composable architecture).