CO3043 - Mobile Application Development
CHAPTER 6
MOBILE APP LIFE CYCLE
AND STATE MANAGEMENT
Hoang Le Hai Thanh
High Performance Computing Laboratory - HCMUT
Today's Agenda
01. 02.
Mobile App Life Cycle iOS & Android App Life Cycle
03. 04.
Mobile App State
Redux Overview
Management
01. Mobile App Life Cycle
Handling Life Cycle in Mobile App is
crucial!
Recall the difference between Mobile Apps and other
platforms:
Activity duration
Hardware resources
Responsiveness
System events
...
Life Cycle Callbacks
Life Cycle Callbacks allow us to know that a state has changed: that the system is creating,
stopping, or resuming our app, or destroying the process in which the app resides.
SOUND SIMILAR?
The key to any robust and efficient mobile app
A good implementation of the lifecycle callbacks can help ensure that your app avoids:
Crashing if the user receives a phone call or switches to another app while using your app.
Consuming valuable system resources when the user is not actively using your app.
Losing the user's progress if they leave your app and return to it at a later time.
Crashing or losing the user's progress when the screen rotates between landscape and
portrait orientation.
....
02.
Android & iOS
App Life Cycle
Android Activity Life Cycle
As a user navigates through, out of, and
back to our app, the Activity instances
transition through different states in their
lifecycle.
iOS Scene Life Cycle
The introduction of multi-window support
on iOS 13 (iPadOS) brings major changes
in application’s life cycle
React Class Component Life Cycle
React Function Component Life Cycle with Hooks
03.
Mobile App
State Management
State
State management is the process of:
Maintain the knowledge of an application's UI
controls across multiple related data flows that
Management form a complete business use case
Understand the condition of the app at any
given moment
Add your Add your
idea here idea here
Local State
Local state is the data that we can neatly manage in a
component.
Global State
Global state is the data that we need to manage across
multiple components
Type of App State
Server State
The server state is the data that comes from an external
The state of an app is everything that exists server that must be integrated with our UI state.
in memory when the app is running
URL State
The URL state is the data that exists on our URLs,
including the pathname and query parameters.
Environment State
The environment state is the information derived from the
device such as permissions, Bluetooth, connectivity state,
etc
04.
Redux Overview
The Prop Drilling Problem
Prop drilling is the problem for passing data
through several nested children components,
in a bid to deliver this data to a deeply-nested
component.
Manage Shared State with Redux
Redux is Event Driven
Actions are dispatched in response to an
event like a UI click
The store runs the reducer function to
calculate a new state based on the event
The UI reads the new state to display the
new values
Thank you :)
Any question?
thanhhoang@[Link]