class ReorderItemsAction(val items: List<Item>) : UpdateAction() data class UpdateItemAction(val localId: String, val text: String?, val color: Color) : UpdateAction() data class UpdateFavoriteAction( val localId: String, val favorite: Boolean) : UpdateAction() data class UpdateColorAction( val localId: String, val color: Color) : UpdateAction() } sealed class ReadAction : Action() { class FetchItemsAction : ReadAction() data class ItemsLoadedAction(val items: List<Item>) : ReadAction() }
ItemsListScreen( val items: List<Item> = emptyList()) data class EditItemScreen(val currentItem: Item = Item()) data class State( val itemsListScreen: ItemsListScreen = ItemsListScreen(), val editItemScreen: EditItemScreen = EditItemScreen(), val navigation: Navigation = Navigation.ITEMS_LIST) Remember, State is immutable.
State = when (action) { is CreationAction -> CreationReducer.reduce(action, currentState) is UpdateAction -> UpdateReducer.reduce(action, currentState) is ReadAction -> ReadReducer.reduce(action, currentState) is DeleteAction -> DeleteReducer.reduce(action, currentState) is NavigationAction -> NavigationReducer.reduce(action, currentState) } }
data class Item( val localId: String = generateLocalId(), val text: String? = null, val favorite: Boolean = false, val color: Color = Color.WHITE, val position: Long = object : PositionsFactory {}.newPosition()) Store Models
-> R.color.red YELLOW -> R.color.yellow GREEN -> R.color.green BLUE -> R.color.blue WHITE -> R.color.white } fun Item.getStableId(): Long = this.localId.hashCode().toLong()
effects as we want. It handles an Action right after the Store has reduced it. It can return a new Action. Extends the functionality of your core logic.
testing easier. Unidirectional makes your code easy to follow. This is not the Philosopher Stone of the architectures. Immutability makes your code safer.
testing easier. Take advantage of the tools you have. Unidirectional makes your code easy to follow. This is not the Philosopher Stone of the architectures. Immutability makes your code safer.
testing easier. Take advantage of the tools you have. What is good for our problem maybe is not good for yours. Unidirectional makes your code easy to follow. This is not the Philosopher Stone of the architectures. Immutability makes your code safer.
G. Valle: Flux on Android André Staltz: Unidirectional data flow architectures Austin Mueller: Flux and Android Brian Egan and Guillaume Lung: Exploring the possibilities of Unidirectional Data Flow Architectures on Android