The document discusses state management and unidirectional data flow in applications. It describes some issues with the traditional MVC pattern for state management. The main concepts of unidirectional data flow are then introduced, including the store, actions, and reducers. An example is provided of how application state can be updated in response to actions via a reducer function. Resources for further learning about unidirectional data flow approaches like Flux and Redux are also listed.
How to submit a standout Adobe Champion Application
State Management & Unidirectional Data Flow
1. @nikolasburkState Management & Unidirectional Data Flow
State Management &
Unidirectional Data Flow
“Where is truth in your application?”
Andy Matuschak, WWDC 2014
6. @nikolasburkState Management & Unidirectional Data Flow
An Application is more than the
Happy Path
“In the context of software or
information modeling, a happy
path is a default scenario
featuring no exceptional or error
conditions.”
Wikipedia 😏
8. The application state represents the
information that is kept in memory of a
running application and is the basis for the
generation of a user interface.
Application State? 🤔
@nikolasburkState Management & Unidirectional Data Flow
9. The application state represents the
information that is kept in memory of a
running application and is the basis for the
generation of a user interface.
Application State? 🤔
@nikolasburkState Management & Unidirectional Data Flow
10. The application state represents the
information that is kept in memory of a
running application and is the basis for
the generation of a user interface.
Application State? 🤔
@nikolasburkState Management & Unidirectional Data Flow
11. @nikolasburkState Management & Unidirectional Data Flow
The main responsibility of an app is to
transform an application state into a user interface.
(AppState) -> UI
12. Example: Conference Planner App 🗓
@nikolasburkState Management & Unidirectional Data Flow
struct Conference {
let name: String
let city: String
let year: String
var attending: Bool
}
16. @nikolasburkState Management & Unidirectional Data Flow
1. Where should the state live?
2. Who is allowed to change the state?
3. How does the state get changed?
3 Golden Questions of
State Management 👑
An architectural pattern should be able to answer these questions!
20. @nikolasburkState Management & Unidirectional Data Flow
How does the state get changed?
KVO & Property Observers
Delegates
Callbacks NSNotificationCenter
Target-Action
3 👑
21. @nikolasburkState Management & Unidirectional Data Flow
UIViewController
What’s wrong with MVC?
Persistence
Networking
Navigation
Domain Logic
User Interface
Concurrency
22. @nikolasburkState Management & Unidirectional Data Flow
State Management is
hard
and MVC is not a solution, thanks Apple 😑
24. @nikolasburkState Management & Unidirectional Data Flow
•
3 Principles
• Single source of truth
• State is read-only
• Changes with pure functions
http://redux.js.org/docs/introduction/ThreePrinciples.html
25. @nikolasburkState Management & Unidirectional Data Flow
Main Concepts
Store:
… manages the application state
… informs subscribers about changes
Actions:
… describe an intent to change the state
Reducer:
… pure functions that generate a new
application state based on actions
28. @nikolasburkState Management & Unidirectional Data Flow
Helpful Resources 📚
• Unidirectional Data Flow in Swift: An Alternative to Massive View
Controllers (Video) (https://realm.io/news/benji-encz-
unidirectional-data-flow-swift/)
• Real World Flux Architecture on iOS (http://blog.benjamin-
encz.de/post/real-world-flux-ios/)
• Redux Documentation (http://redux.js.org/)
• Advanced iOS Application Architecture and Patterns, Andy
Matuschak WWDC 2014 (Video) (http://asciiwwdc.com/2014/
sessions/229)