Sample application to show state management & unidirectional data flow using Jetpack compose.

Overview

Jetpack Compose State Management

A sample project to demonstrate State Management in Jetpack compose by following This CodeLab.

Through the project you can get acquainted with

  1. What is unidirectional data flow
  2. How to think about state and events in a UI
  3. How to use Architecture Component's ViewModel and LiveData in Compose to manage state
  4. How Compose uses state to draw a screen
  5. State hoisting
  6. How to use internal state in Compose
  7. How to use State<T> to integrate state with Compose
  8. Test State in ViewModel

Unidirectional Data Flow

In Android apps, state is updated in response to events. Events are inputs generated from outside our application, such as the user tapping on a button calling an OnClickListener, an EditText calling afterTextChanged, or an accelerometer sending a new value.

Events notify a part of a program that something has happened.

For example, a user pressing a button will call a click event.

In all Android apps, there's a core UI update loop that goes like this:

Event – An event is generated by the user or another part of the program

Update State – An event handler changes the state that is used by the UI

Display State – The UI is updated to display the new state

Managing state in Compose is all about understanding how state and events interact with each other.

Unidirectional data flow is a design where events flow up and state flows down.

For example, in a ViewModel events are passed up with method calls from the UI while state flows down using LiveData.

It's not just a term to describe ViewModel – any design where events flow up and state goes down is unidirectional.

Implementation

You might also like...
Sample to show how to implement blur graphical tricks
Sample to show how to implement blur graphical tricks

BlurEffectForAndroidDesign Sample to show how to implement blur graphical tricks All the explanations could be found here: http://nicolaspomepuy.fr/?p

Dynamic-UI-From-JSON - A Sample Android app to show dynamic UI generation from Json
Dynamic-UI-From-JSON - A Sample Android app to show dynamic UI generation from Json

Dynamic UI from JSON Functionality The app's functionality includes: The app gen

Movies-db-example - Sample Android application that loads movies data from a remote server

Movies Application Sample Android application that loads movies data from a remo

Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item
Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item

Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item

Powerful, comprehensice application performance management platform of Android

OutSiderAPM移动性能监控平台(持续开发中) 项目优势 实时掌控应用性能 降低性能定位成本 有效提升用户体验 监控模块 OutSiderAPM目前支持如下性能指标: 交互分析:分析Activity生命周期耗时,帮助提升页面打开速度,优化用户UI体验 网络请求分析:监控流量使用情况,发现并定位

This todolist android app is for task management and it is made using kotlin
This todolist android app is for task management and it is made using kotlin

This new android application named 'TODO-LIST APP' is created by Biswarup Bhattacharjee, student of BTECH, in University of Engineering and Management, Kolkata.

CMPLR-Native - A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding
(Coroutine, Flow(+StateFlow), Hilt, JetPack, MVVM, Repository Pattern, Retrofit2 & OkHttp3, Moshi, Glide, Timber, Material-Components)

(Coroutine, Flow(+StateFlow), Hilt, JetPack, MVVM, Repository Pattern, Retrofit2 & OkHttp3, Moshi, Glide, Timber, Material-Components)

Simple Notes app demonstrates modern Android development with Hilt, Material Motion, Coroutines, Flow, Jetpack (Room, ViewModel) based on MVVM architecture.
Simple Notes app demonstrates modern Android development with Hilt, Material Motion, Coroutines, Flow, Jetpack (Room, ViewModel) based on MVVM architecture.

Simple Notes app demonstrates modern Android development with Hilt, Material Motion, Coroutines, Flow, Jetpack (Room, ViewModel) based on MVVM architecture.

Owner
Rafsan Ahmad
Software developer...Crafting apps to perfection
Rafsan Ahmad
MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK

MvvmKotlinJetpackCompose Why do we need an architecture even when you can make an app without it? let's say you created a project without any architec

Sayyed Rizwan 46 Nov 29, 2022
Shreyas Patil 2.1k Dec 30, 2022
A simple NewsApp built using Jetpack Compose, MVVM Architecture, Dagger Hilt and Kotlin Flow

NewsApp is simple App which uses NewsAPI to get top headlines for country you live in or you can search for a specific news. Focus of this app is to d

ElvisOperator 4 Aug 20, 2022
An android application which uses HBO's Silicon Valley data (Mockable.io) for listing TV show episodes.

TVShowCaseApp An android application which uses HBO's Silicon Valley data (Mockable.io) for listing TV show episodes. Prerequisites 1. Check the API I

Çağatay Kölüş 1 Oct 26, 2021
App made using Kotlin to retrieve data from an API and show in a recyclerview with Login and SignUp features

App made using Kotlin to retrieve data from an API and show in a recyclerview with Login and SignUp features.

Altair Wallace 1 Feb 17, 2022
A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding It's a mimic for Tumblr application , But a little prettier than him 😉

A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding It's a mimic for Tum

Ahmed Ihab 17 Dec 23, 2022
FlowDroid Static Data Flow Tracker

FlowDroid Data Flow Analysis Tool This repository hosts the FlowDroid data flow analysis tool. FlowDroid statically computes data flows in Android app

Secure Software Engineering Group at Paderborn University and Fraunhofer IEM 801 Dec 28, 2022
🦄 Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.

?? Android Pokedex-AR using ARCore, Sceneform, Hilt, Coroutines, Flow, Jetpack (Room, ViewModel, LiveData) based on MVVM architecture.

Jaewoong Eum 535 Dec 9, 2022
Note taking app using MVVM architecture with Hilt, Material Motion, Coroutines, Flow, Jetpack

Note taking app using MVVM architecture with Hilt, Material Motion, Coroutines, Flow, Jetpack (Room, ViewModel,Paging3).

Ranbir Singh 7 Apr 25, 2022
The JeTrivia is built on a modern Android Development tech stack with MVVM architecture. Kotlin, Coroutine, Flow, StateFlow, Jetpack Compose, Navigation, Room, Hilt, Retrofit2, OkHttp3, kotlinx.serialization, MockK, Truth

JeTrivia ?? In Progress ?? The JeTrivia application is sample based on MVVM architecture. Fetching data from the network via repository pattern and sa

Tolga Bolatcan 5 Mar 31, 2022