intro to flux - reactjs warsaw #1

35
Intro to Flux Damian Legawiec CEO of Spark Solutions @damianlegawie c

Upload: damian-legawiec

Post on 15-Apr-2017

2.061 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Intro to Flux - ReactJS Warsaw #1

Intro to Flux

Damian LegawiecCEO of Spark Solutions

@damianlegawiec

Page 2: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Framework?

Page 3: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Framework?

Library?

Page 4: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Framework?

Library? Kinda :)

Page 5: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Architecture Pattern

Page 6: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Architecture PatternOne Way Data Binding

Page 7: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Architecture PatternOne Way Data BindingFramework Agnostic

Page 8: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Architecture PatternOne Way Data BindingFramework Agnostic

Not MVC :)

Page 9: Intro to Flux - ReactJS Warsaw #1

What is Flux?

Page 10: Intro to Flux - ReactJS Warsaw #1

Store

Model?

Page 11: Intro to Flux - ReactJS Warsaw #1

Store

Model?

Page 12: Intro to Flux - ReactJS Warsaw #1

Store

Model?Collection?

Page 13: Intro to Flux - ReactJS Warsaw #1

Store

Model?Collection?

Page 14: Intro to Flux - ReactJS Warsaw #1

Store

Application State Container

Page 15: Intro to Flux - ReactJS Warsaw #1

Store

Application State ContainerCan be used with ORM

Page 16: Intro to Flux - ReactJS Warsaw #1

Store

Application State ContainerCan be used with ORM

Simple JavaScript object enhanced by EventEmitter or MicroEvent

Page 17: Intro to Flux - ReactJS Warsaw #1

Actions

Used to invoke Change of state

Page 18: Intro to Flux - ReactJS Warsaw #1

Actions

Used to invoke Change of stateInvoked from Views (Components in React)

Actions

Page 19: Intro to Flux - ReactJS Warsaw #1

Actions

Used to invoke Change of stateInvoked from Views (Components in React)

They pass arguments (payload) to Dispatcher

Actions

Page 20: Intro to Flux - ReactJS Warsaw #1

Dispatcher

There can be only one!

Actions

Page 21: Intro to Flux - ReactJS Warsaw #1

Dispatcher

There can be only one!Dispatches Actions to the Store

DispatcherActions

Page 22: Intro to Flux - ReactJS Warsaw #1

Smart Components

Aware of Store

Page 23: Intro to Flux - ReactJS Warsaw #1

Smart Components

Aware of StoreListen for Store change

Page 24: Intro to Flux - ReactJS Warsaw #1

Smart Components

Aware of StoreListen for Store change

Data is in State

Page 25: Intro to Flux - ReactJS Warsaw #1

Smart ComponentsAware of Store

Listen for Store changeData is in State

Pass data via props to Dumb Components

Page 26: Intro to Flux - ReactJS Warsaw #1

Dumb Components

Only display data passed in props

Page 27: Intro to Flux - ReactJS Warsaw #1

Single Page App Example

https://greetabl.com/builder

Page 28: Intro to Flux - ReactJS Warsaw #1

Web App Example

https://milanstyle.com

Page 29: Intro to Flux - ReactJS Warsaw #1

When to use Flux?

Single Page AppComplex UI

Real World apps :)

Page 30: Intro to Flux - ReactJS Warsaw #1

When not to use Flux?

Learning React :)Simple components enhancing static site

Page 31: Intro to Flux - ReactJS Warsaw #1

What is Flux implementation use?

Short AnswerREDUX

Page 32: Intro to Flux - ReactJS Warsaw #1

What is Flux implementation use?

Long Answer

Page 33: Intro to Flux - ReactJS Warsaw #1

What is Flux implementation use?

1. Start with official Facebook one2. Choose between more conventional

ones (Reflux, Alt) or bleeding edge Redux