class: center, middle background-image: url(img/mire.jpg) .footnote.preintro[Connection to projector seems good, we can start] --- name: inverse layout: true class: inverse --- class: center, middle #What the Flux? .footnote[http://twidi.github.io/what-the-flux/] --- class: center # Presentation in 3 parts: .left[
##I. Theory
##II. Practice
##III. “Flux-react” ] .footnote[Part I and II are (very) highly inspired by a [blog post by Jonathan Creamer](http://jonathancreamer.com/what-the-flux/)] --- class: center, middle # I. Theory --- class: center, middle #“Flux”, a
concept
from Facebook .footnote[Boooh, bad guys. But they made React.] --- class: center, middle ## “Application
Architecture
for Building User Interfaces” .footnote[For React. Or not] --- class: center, middle ## Some excerpts... .footnote[Read them. No, I'm kidding ;)] --- class: justified, middle > “Flux applications have three major parts: the dispatcher, the stores, and the views (React components).” .footnote[Even my child could understand this one] --- class: justified, middle > “These should not be confused with Model-View-Controller. Controllers do exist in a Flux application, but they are controller-views — views often found at the top of the hierarchy that retrieve data from the stores and pass this data down to their children.” .footnote[Even mYk has to read it again] --- class: justified, middle > “Additionally, action creators — dispatcher helper methods — are used to support a semantic API that describes all changes that are possible in the application.” .footnote[Seriously, make an effort] --- class: justified, middle > “Flux eschews MVC in favor of a unidirectional data flow.” .footnote[Understood?] --- class: justified, middle > When a user interacts with a React view, the view propagates an action through a central dispatcher, to the various stores that hold the application's data and business logic, which updates all of the views that are affected. .footnote[Is everything clear?] --- class: center, middle  --- class: center, middle ## OK, maybe with a diagram .footnote[Hold on...] --- class: center, middle background-image: url(img/flux-diagram.png) --- class: center, middle  --- class: center, middle ## Let's rework a little .footnote[It's all about some stuff] --- class: center, middle background-image: url(img/flux-diagram-easy.jpg) --- class: center, middle background-image: url(img/flux-diagram.png) --- class: center, middle background-image: url(img/flux-diagram-easy.jpg) --- class: center, middle background-image: url(img/flux-diagram.png) --- class: center, middle # II. Practice
## Let's break this all down... .footnote[Oh yes daddy, show us some code!] --- class: center, middle # Think “EVENTS” .footnote[Or dispatcher, ... It's how everything happen] --- class: twocols-inverse layout: false .left-column[ ## View ] .right-column[.middle[.center.alone[ # Show some stuff ]]] --- .left-column[ ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- class: twocols-inverse .left-column[ ## View ## Action Creators ] .right-column[.middle[.center.alone[ # Go get some more stuff ]]] --- .left-column[ ## View ## Action Creators .detail[Go get some more stuff] ] .right-column[.middle[ ### - What's the main purpose in life of an "action creator"? ### - *To create actions?* ### - Yes ### - *It was hard!* ### - I know ### - *...* ### - But note that "creating" an action, is actually doing it ### - *Kill me* ]] --- class: twocols-inverse .left-column[ ## View ## Action Creators ## Actions ] .right-column[.middle[.center.alone[ # Do something with stuff ]]] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define allowed actions .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define the actions .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define the actions .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define the actions .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define the actions .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Actually do something .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define the actions .img-code[] ] --- .left-column[ ## View ## Action Creators ## Actions .detail[Do something with stuff] ] .right-column[ ## Define the actions .img-code[] ] --- class: twocols-inverse .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ] .right-column[.middle[.center.alone[ # Hey Everyone! There's new stuff! ]]] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher .detail[Hey Everyone! There's new stuff!] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher .detail[Hey Everyone! There's new stuff!] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher .detail[Hey Everyone! There's new stuff!] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher .detail[Hey Everyone! There's new stuff!] ] .right-column[ .middle[.img-code[]] ] --- class: twocols-inverse .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store ] .right-column[.middle[.center.alone[ # Keep track of stuff ]]] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ ## Main points:
> “Stores hold application state and business logic”
> “Stores are also emitters” ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store .detail[Keep track of stuff] ] .right-column[ .middle[.img-code[]] ] --- class: twocols-inverse .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store ## View, again .detail[It's a loop, remember] ] .right-column[.middle[.center.alone[ # Change events ]]] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store ## View .detail[Change events] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store ## View .detail[Change events] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## View ## Action Creators ## Actions ## Dispatcher ## Store ## View .detail[Change events] ] .right-column[ .middle[.img-code[]] ] --- class: inverse, center #Summary
.left[ View renders ↪ Click triggers action creator ↪ Go get data ↪ Create action for received data ↪ Send action to dispatcher ↪ Dispatcher publishes action ↪ Store listens for action ↪ Store updates state ↪ View updates ] --- class: center, middle background-image: url(img/please-simple.jpg) --- class: inverse, center, middle #III. Introducing “flux-react” .footnote[by [Christian Alfoni](https://github.com/christianalfoni/flux-react/)] --- class: inverse, center #Same concepts, but takes care of the dispatcher for you, so:
.left[
- less code
- less repetitions
- better view of the whole process ] --- class: inverse, center, middle # Same example .footnote[MOAR CODE!] --- class: twocols-inverse .left-column[ ## Actions ] .right-column[.middle[.center.alone[ # What stuff we can do ]]] --- .left-column[ ## Actions .detail[What stuff we can do] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions .detail[What stuff we can do] ] .right-column[ .middle[.img-code[]] ] --- class: twocols-inverse .left-column[ ## Actions ## Store ] .right-column[.middle[.center.alone[ # Work on stuff ]]] --- .left-column[ ## Actions ## Store .detail[Work on stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store .detail[Work on stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store .detail[Work on stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store .detail[Work on stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store .detail[Work on stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store .detail[Work on stuff] ] .right-column[ .middle[.img-code[]] ] --- class: twocols-inverse .left-column[ ## Actions ## Store ## View ] .right-column[.middle[.center.alone[ # Show some stuff ]]] --- .left-column[ ## Actions ## Store ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- .left-column[ ## Actions ## Store ## View .detail[Show some stuff] ] .right-column[ .middle[.img-code[]] ] --- class: inverse, center # I'm done
## How do you feel?
.pull-left[ Good...  ] .pull-right[ Or still...  ] --- class: inverse, center, middle # THANK YOU! .footnote[This presentation was proposed to you by [Stéphane "Twidi" Angel](http://twidi.com)] --- class: center, middle background-image: url(img/mire.jpg) .footnote.preintro[Signal lost...]