47
Flux …a Pattern

Flux

Embed Size (px)

Citation preview

Page 1: Flux

Flux…a Pattern

Page 2: Flux

Prologue

Page 3: Flux

“Sometimes you gotta go back to actually move forward.”

-Matthew McConaughey

Page 4: Flux

A long time ago in a PARC far, far away….

Page 5: Flux

SMALLTALK-80

Page 6: Flux

History

Page 7: Flux
Page 8: Flux
Page 9: Flux
Page 10: Flux
Page 11: Flux

Fast Forward

Page 12: Flux

Rails

Page 13: Flux

Cocoa

Page 14: Flux

Client-side MV* JavaScript Frameworks

Page 15: Flux

The Good Parts

Page 16: Flux

Familiarity

Page 17: Flux

They Makes (Some) Things Simple

Page 18: Flux

Dynamic User Experience

Page 19: Flux

The Not So Good Parts

Page 20: Flux

Lack of Consensus

Page 21: Flux
Page 22: Flux
Page 23: Flux

Much Fowler

So Insightwow

Very Martin

how enterprise

Page 24: Flux
Page 25: Flux

Complex Models

Page 26: Flux
Page 27: Flux

Data Binding Solutions

Page 28: Flux
Page 29: Flux

Framework Support

Page 30: Flux

Compatibility

Page 31: Flux

Templating

Page 32: Flux

Enough Complaining…

Page 33: Flux

What the Flux?

Unidirectional Data Flow

Conceptual Integrity“a system must have a powerful metaphor that is uniformly applied throughout a system“ – Alan

Kay

Move Fast With Stable Infrastructure

Reliability

Page 34: Flux

The Pieces

Page 35: Flux

Views

React Components

Maintain UI State

Respond to changes in Stores

Render data, respond to interaction

Controller-Views

Page 36: Flux

Stores

Maintain Application State

Each Store manages a particular domain within the app

Similar to Models, but manage many objects

Emit change events

Page 37: Flux

Actions

Can be anything that changes the state of your data

User generated events

Server events

Real time updates

Error Handling

Page 38: Flux

Dispatcher

Key to unidirectional data flow

Central Hub/Callback Registry

Manages dependencies between StoreswaitFor(ids)

Keeps State in Stores, closer to the logic that updates that State

Page 39: Flux

The Pattern

Page 40: Flux

Dispatcher

Profile Controller-

ViewProfile Store

Notification Store

Chat Store

Prefs

Pic

Notification Controller-

View

ChatController-

View

Server New Message Action

Pic Changed Action

Page 41: Flux

Action Dispatcher ViewStore

Action

Server

Page 42: Flux

Code

Page 45: Flux

Presentation Resources

Model View Controller: History, Theory and Usage

MVC: Xerox PARC 1978-79

Model View Controller History

Page 46: Flux

Questions?

Page 47: Flux

How do we convince people that in programming simplicity and clarity —in short: what mathematicians call "elegance"— are not a dispensable luxury, but a crucial matter that decides between success and failure?

Edsger Dijkstra