SlideShare ist ein Scribd-Unternehmen logo
1 von 40
Downloaden Sie, um offline zu lesen
Sidiq Permana
CIO-Nusantara Beta Studio, GDE Android, Intel Software Innovator
State management refers to the management of the state of one or more
user interface controls such as text fields, OK buttons, radio buttons, etc. in a
graphical user interface. In this user interface programming technique, the state
of one UI control depends on the state of other UI controls. For example, a state
managed UI control such as a button will be in the enabled state when input fields
have valid input values and the button will be in the disabled state when the input
fields are empty or have invalid values. As applications grow, this can end up
becoming one of the most complex problems in user interface development.
"Motivation · Redux". redux.js.org. Retrieved 2019-07-23.
1. Lifecycle in core components
2. State in Android Views
3. LiveData and ViewModel
4. DataBinding
5. Observable Object
Android Views like View, TextView, Button etc manage their state by
themselves and exposing the access through methods or properties to their
consumer to manipulate it.
1. Event: An event is generated by part of the UI, able to be triggered by
the users and passed up.
2. Update state: An event handler may change the state.
3. Display state: The state is passed down, and the UI observes the new
state and displays it.
1. Event: User Clicks the Button.
2. Update state: onClickListener() or method update the state to start
processing the task.
3. Display state: updated state to be shown as result.
1. Testability: by decoupling state from the UI that displays it, it's easier to
test both in isolation.
2. State encapsulation: because state can only be updated in one place,
it's less likely that you'll create inconsistent states (or bugs).
3. UI consistency: all state updates are immediately reflected in the UI by
the use of observable state holders.
1. State<T>
2. MutableState<T>
Transform the LiveData object to State by utilize its extension function
LiveData<T>.observeAsState()
1. Memoization with remember(){ /** DEFAULT **/ }
2. Stateful Composable
3. Stateful Composable
4. Hoisting State
5. Internal State
In computing, memoization or memoisation is an optimization technique used
primarily to speed up computer programs by storing the results of expensive
function calls and returning the cached result when the same inputs occur
again.
https://en.wikipedia.org/wiki/Memoization
remember(){ /** DEFAULT **/ } gives a composable function memory and to
store objects in the Composition, and forgets the object when the
composable that called remember is removed from the Composition.
This mechanism impacts when the process of initial composition and
recomposition.
In an imperative UI model, to change a widget, you call a setter on the
widget to change its internal state. In Compose, you call the composable
function again with new data. Doing so causes the function to be
recomposed--the widgets emitted by the function are redrawn, if
necessary, with new data. The Compose framework can intelligently
recompose only the components that changed.
A Composition can only be produced by an initial composition and
updated by recomposition. The only way to modify a Composition is
through recomposition.
A stateless composable is a composable that cannot change any state
itself. The main responsibility of this composable is to show the data
and receive the event. Stateless components are easier to test, tend to
have fewer bugs, and open up more opportunities for reuse.
A stateful composable can directly hold,
change or mutate state.
Compose is a pattern of moving state to a composable's caller to make a
composable stateless. The general pattern for state hoisting in Jetpack
Compose is to replace the state variable with two parameters:
● value: T: the current value to display
● onValueChange: (T) -> Unit: an event that requests the value to change,
where T is the proposed new value
● Single source of truth: by moving state instead of duplicating it, we're ensuring
there's only one source of truth for expanded. This helps avoid bugs.
● Encapsulated: only stateful Composable will be able to modify its state. It's
completely internal.
● Shareable: hoisted state can be shared with multiple composables. Say we
wanted to hide a Fab button when the Card is expanded, hoisting would allow us
to do that.
● Interceptable: callers to the stateless Composable can decide to ignore or modify
events before changing the state.
● Decoupled: the state for the stateless Composable may be stored anywhere. For
example, it's now possible to move title, body, and expanded into a ViewModel.
● Reusable: Making the stateless composable reusable for other purpose but with
the same form.
When hoisting state, there are three rules to help you figure out where state
should go:
1. State should be hoisted to at least the lowest common parent of all
composables that use the state (read).
2. State should be hoisted to at least the highest level it may be changed
(write).
3. If two states change in response to the same events they should be
hoisted together.
You can hoist state higher than these rules require, but underhoisting state
will make it difficult or impossible to follow unidirectional data flow.
Values that are remembered by remember in a Composition are forgotten
and recreated during configuration changes such as rotation.
The solution is to switch to composable function SaveInstanceState<T>
1. Managing state is a state of art that becomes the most challenging thing
in software development
2. Jetpack Compose aims that state are transparent and controlled by the
developer
3. Unidirectional Data Flow offers the testability, state encapsulation and UI
Consistency
4. Memoization helps in performance during recomposition process
5. State Hoisting will give benefit and making composable owns their
Responsibility
Contact:
sidiq@nbs.co.id
Follow Instagram:
sidiqpermana10

Weitere ähnliche Inhalte

Ähnlich wie Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana

Angular js meetup
Angular js meetupAngular js meetup
Angular js meetup
Anton Kropp
 

Ähnlich wie Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana (20)

FRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptxFRONTEND BOOTCAMP 4.pptx
FRONTEND BOOTCAMP 4.pptx
 
Redux
ReduxRedux
Redux
 
How to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooksHow to build a react native app with the help of react native hooks
How to build a react native app with the help of react native hooks
 
A NEW INNOVATION TECHNIQUE OF STATE TRANSITION TESTING USED FOR DBT
A NEW INNOVATION TECHNIQUE OF STATE TRANSITION TESTING USED FOR DBTA NEW INNOVATION TECHNIQUE OF STATE TRANSITION TESTING USED FOR DBT
A NEW INNOVATION TECHNIQUE OF STATE TRANSITION TESTING USED FOR DBT
 
an Introduction to Redux
an Introduction to Reduxan Introduction to Redux
an Introduction to Redux
 
Lagom - Persistent Entity
Lagom - Persistent EntityLagom - Persistent Entity
Lagom - Persistent Entity
 
State Pattern In Flex
State Pattern In FlexState Pattern In Flex
State Pattern In Flex
 
Mobx for Dummies - Yauheni Nikanowich - React Warsaw #5
Mobx for Dummies - Yauheni Nikanowich - React Warsaw #5Mobx for Dummies - Yauheni Nikanowich - React Warsaw #5
Mobx for Dummies - Yauheni Nikanowich - React Warsaw #5
 
Everything to Know About React Re-Rendering: A Comprehensive Guide
Everything to Know About React Re-Rendering: A Comprehensive GuideEverything to Know About React Re-Rendering: A Comprehensive Guide
Everything to Know About React Re-Rendering: A Comprehensive Guide
 
Reduxing UI: Borrowing the Best of Web to Make Android Better
Reduxing UI: Borrowing the Best of Web to Make Android BetterReduxing UI: Borrowing the Best of Web to Make Android Better
Reduxing UI: Borrowing the Best of Web to Make Android Better
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
 
STATE-MANAGEMENT-IN-FLUTTER-TECHNOLOGY.pptx
STATE-MANAGEMENT-IN-FLUTTER-TECHNOLOGY.pptxSTATE-MANAGEMENT-IN-FLUTTER-TECHNOLOGY.pptx
STATE-MANAGEMENT-IN-FLUTTER-TECHNOLOGY.pptx
 
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
Advanced Redux architecture - WHAT/WHEN/WHY/HOWAdvanced Redux architecture - WHAT/WHEN/WHY/HOW
Advanced Redux architecture - WHAT/WHEN/WHY/HOW
 
React state
React  stateReact  state
React state
 
Understanding React hooks | Walkingtree Technologies
Understanding React hooks | Walkingtree TechnologiesUnderstanding React hooks | Walkingtree Technologies
Understanding React hooks | Walkingtree Technologies
 
Angular js meetup
Angular js meetupAngular js meetup
Angular js meetup
 
React Workshop: Core concepts of react
React Workshop: Core concepts of reactReact Workshop: Core concepts of react
React Workshop: Core concepts of react
 
React JS Interview Question & Answer
React JS Interview Question & AnswerReact JS Interview Question & Answer
React JS Interview Question & Answer
 
Write better, stronger, faster behat steps with ScenarioStateBehatExtension
Write better, stronger, faster behat steps with ScenarioStateBehatExtensionWrite better, stronger, faster behat steps with ScenarioStateBehatExtension
Write better, stronger, faster behat steps with ScenarioStateBehatExtension
 
Redux State Management System A Comprehensive Review
Redux State Management System A Comprehensive ReviewRedux State Management System A Comprehensive Review
Redux State Management System A Comprehensive Review
 

Mehr von DicodingEvent

Mehr von DicodingEvent (20)

Developer Coaching #114.pdf
Developer Coaching #114.pdfDeveloper Coaching #114.pdf
Developer Coaching #114.pdf
 
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
 
tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21
 
Mengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchatMengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchat
 
Membangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWSMembangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWS
 
IDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational ThinkingIDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational Thinking
 
Membuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup UnicornMembuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup Unicorn
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
 
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CDTechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
 
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur RohmanMembuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
 
Potensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depanPotensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depan
 
Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101
 
Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021
 
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew KurniadiTeknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
 
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
 
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi BarusPengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
 
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
 
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
 
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
 

Kürzlich hochgeladen

Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
Kayode Fayemi
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
raffaeleoman
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
amilabibi1
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
Kayode Fayemi
 

Kürzlich hochgeladen (18)

Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
 
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdfAWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
AWS Data Engineer Associate (DEA-C01) Exam Dumps 2024.pdf
 
lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.lONG QUESTION ANSWER PAKISTAN STUDIES10.
lONG QUESTION ANSWER PAKISTAN STUDIES10.
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptx
 
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
Aesthetic Colaba Mumbai Cst Call girls 📞 7738631006 Grant road Call Girls ❤️-...
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of DrupalDigital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 

Jetpack Compose untuk UI Masa Depan Bagian 2 - Sidiq Permana

  • 1. Sidiq Permana CIO-Nusantara Beta Studio, GDE Android, Intel Software Innovator
  • 2.
  • 3. State management refers to the management of the state of one or more user interface controls such as text fields, OK buttons, radio buttons, etc. in a graphical user interface. In this user interface programming technique, the state of one UI control depends on the state of other UI controls. For example, a state managed UI control such as a button will be in the enabled state when input fields have valid input values and the button will be in the disabled state when the input fields are empty or have invalid values. As applications grow, this can end up becoming one of the most complex problems in user interface development. "Motivation · Redux". redux.js.org. Retrieved 2019-07-23.
  • 4.
  • 5. 1. Lifecycle in core components 2. State in Android Views 3. LiveData and ViewModel 4. DataBinding 5. Observable Object
  • 6.
  • 7.
  • 8. Android Views like View, TextView, Button etc manage their state by themselves and exposing the access through methods or properties to their consumer to manipulate it.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17. 1. Event: An event is generated by part of the UI, able to be triggered by the users and passed up. 2. Update state: An event handler may change the state. 3. Display state: The state is passed down, and the UI observes the new state and displays it.
  • 18. 1. Event: User Clicks the Button. 2. Update state: onClickListener() or method update the state to start processing the task. 3. Display state: updated state to be shown as result.
  • 19.
  • 20. 1. Testability: by decoupling state from the UI that displays it, it's easier to test both in isolation. 2. State encapsulation: because state can only be updated in one place, it's less likely that you'll create inconsistent states (or bugs). 3. UI consistency: all state updates are immediately reflected in the UI by the use of observable state holders.
  • 21.
  • 22. 1. State<T> 2. MutableState<T> Transform the LiveData object to State by utilize its extension function LiveData<T>.observeAsState()
  • 23. 1. Memoization with remember(){ /** DEFAULT **/ } 2. Stateful Composable 3. Stateful Composable 4. Hoisting State 5. Internal State
  • 24. In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. https://en.wikipedia.org/wiki/Memoization
  • 25. remember(){ /** DEFAULT **/ } gives a composable function memory and to store objects in the Composition, and forgets the object when the composable that called remember is removed from the Composition. This mechanism impacts when the process of initial composition and recomposition.
  • 26.
  • 27. In an imperative UI model, to change a widget, you call a setter on the widget to change its internal state. In Compose, you call the composable function again with new data. Doing so causes the function to be recomposed--the widgets emitted by the function are redrawn, if necessary, with new data. The Compose framework can intelligently recompose only the components that changed. A Composition can only be produced by an initial composition and updated by recomposition. The only way to modify a Composition is through recomposition.
  • 28.
  • 29. A stateless composable is a composable that cannot change any state itself. The main responsibility of this composable is to show the data and receive the event. Stateless components are easier to test, tend to have fewer bugs, and open up more opportunities for reuse.
  • 30.
  • 31. A stateful composable can directly hold, change or mutate state.
  • 32.
  • 33. Compose is a pattern of moving state to a composable's caller to make a composable stateless. The general pattern for state hoisting in Jetpack Compose is to replace the state variable with two parameters: ● value: T: the current value to display ● onValueChange: (T) -> Unit: an event that requests the value to change, where T is the proposed new value
  • 34. ● Single source of truth: by moving state instead of duplicating it, we're ensuring there's only one source of truth for expanded. This helps avoid bugs. ● Encapsulated: only stateful Composable will be able to modify its state. It's completely internal. ● Shareable: hoisted state can be shared with multiple composables. Say we wanted to hide a Fab button when the Card is expanded, hoisting would allow us to do that. ● Interceptable: callers to the stateless Composable can decide to ignore or modify events before changing the state. ● Decoupled: the state for the stateless Composable may be stored anywhere. For example, it's now possible to move title, body, and expanded into a ViewModel. ● Reusable: Making the stateless composable reusable for other purpose but with the same form.
  • 35.
  • 36. When hoisting state, there are three rules to help you figure out where state should go: 1. State should be hoisted to at least the lowest common parent of all composables that use the state (read). 2. State should be hoisted to at least the highest level it may be changed (write). 3. If two states change in response to the same events they should be hoisted together. You can hoist state higher than these rules require, but underhoisting state will make it difficult or impossible to follow unidirectional data flow.
  • 37. Values that are remembered by remember in a Composition are forgotten and recreated during configuration changes such as rotation. The solution is to switch to composable function SaveInstanceState<T>
  • 38.
  • 39. 1. Managing state is a state of art that becomes the most challenging thing in software development 2. Jetpack Compose aims that state are transparent and controlled by the developer 3. Unidirectional Data Flow offers the testability, state encapsulation and UI Consistency 4. Memoization helps in performance during recomposition process 5. State Hoisting will give benefit and making composable owns their Responsibility