SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
A J O U R N E Y W I T H R E A C T
TA S V E E R S I N G H
@ t a z s i n g h
3 A P P S
– M I K E H O U R A H I N E
“You can learn trigonometry, physics, C++, and DirectX to make a video game.
Or you can make a video game and learn DirectX, C++, physics, and
trigonometry.”
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
A P P # 1 - R E A C T A S A T E M P L AT I N G E N G I N E
• Server side application framework
• Nashorn JavaScript engine for Java 8
• Vert.x 2.3 - Polyglot Event-Driven Messaging
• Innovative Router
• React to describe HTML
A P P # 2 - F L U X
M
C
C
C
C
V
V
V
V
M
M
C
C
C
C
V
V
V
V
M
A P P # 2 - F L U X
• My first iteration relied on my experience from MVC
• Business logic resides in Models/Stores
• Fat models, skinny controllers
• Models/Stores make AJAX calls
• Actions were very light weight notifications to the Stores
function signInUser(username, password) {
Dispatcher.dispatch({
type: ActionTypes.USER_SIGN_IN
, username: username
, password: password
});
}
class UserStore extends EventEmitter {
currentUser = null;
dispatchToken = Dispatcher.register((action) => {
switch(action.type) {
case ActionTypes.USER_SIGN_IN:
fetchUser(action.username, action.password).then(
(response) => {
this.currentUser = response.user;
this.emit(“change”);
});
}
});
}
function getState() {
return { currentUser: UserStore.currentUser }
}
class SignInComponent extends React.Component {
state = getState();
handleStateChange() { this.setState(getState()); }
componentDidMount() { UserStore.on(“change”, this.handleStateChange); }
componentWillUnmount() {
UserStore.removeListener(“change”, this.handleStateChange);
}
handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your
password?”)); }
render() {
if(!this.state.currentUser)
return <a onClick={this.handleAuth}>Click here to sign in</a>;
else
return <p>You’re signed in as {this.state.currentUser.name}</p>;
}
}
A P P # 2 - F L U X - F I R S T I T E R AT I O N
• Facebook’s Dispatcher does not allow you to dispatch from a dispatch
• Difficult to compose application flow
• How do you handle errors?
• Relies on the Global State of ActionTypes
• Views worked great!
N E X T I T E R AT I O N
T RY C O M P O S I N G A C T I O N S
class SignInUser extends BaseAction {
constructor(username, password, alreadySignedInUser) {
this.username = username;
this.password = password;
this.alreadySignedInUser = alreadySignedInUser;
if(!this.alreadySignedInUser) this.authUser();
}
authUser() {
fetchUser(this.username, this.password).then(
(newUser) => { new SignInSuccess(newUser); }
, (errors) => { new SignInFailure(errors); }
);
}
class SignInUser extends BaseAction {
constructor(username, password, alreadySignedInUser) {
this.username = username;
this.password = password;
this.alreadySignedInUser = alreadySignedInUser;
if(!this.alreadySignedInUser) this.authUser();
}
authUser() {
fetchUser(this.username, this.password).then(
(newUser) => { new SignInSuccess(newUser); }
, (errors) => { new SignInFailure(errors); }
);
}
class SignInSuccess
extends BaseAction {
constructor(newUser) {
this.newUser =
newUser;
this.dispatch();
}
}
class SignInFailure
extends BaseAction {
constructor(errors) {
this.errors = errors;
this.dispatch();
new
FlashMessage(“Could not
sign in”);
}
}
class UserStore extends EventEmitter {
currentUser = null;
dispatchToken = Dispatcher.register((action) => {
switch(action.constructor) {
case SignInSuccess:
this.currentUser = action.newUser;
this.emit(“change”);
}
});
}
A P P # 2 - F L U X - 2 N D I T E R AT I O N
• Eliminates the “dispatching from a dispatch” problem
• Stores are synchronous
• Very easy to compose the flow of your application by composing actions
• Eliminated Global State of ActionTypes
• Extremely scalable solution
• Easy to test
• In a later iteration, dropped in WebPack
A P P # 3 - B R O C H U R E W E B S I T E
A P P # 3 - B R O C H U R E W E B S I T E
• SEO is paramount
• AJAX is bad for SEO
• Performant on Desktop and Mobile
• Server Side Rendered
• Incremental Loading
• Introduce server side developers to client side technologies
• ES6/ES2015 via Babel
• React + Flux + WebPack
A P P # 3 - B R O C H U R E W E B S I T E
• Server side React + Server side Flux
• WebPack manages front end assets, inlining, and chunking
• Incremental loading by chunking
• Reduce number of web requests by inlining
• Koa.js serves the application and handles routing
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
G R I F F I N . J S
G R I F F I N . J S
• Includes everything I’ve learnt and more
• Facebook’s Dispatcher
• React Views
• Griffin Actions - Same as previous examples
• Redux Stores w/ Griffin Connector to Views
class UserStore extends EventEmitter {
currentUser = null;
dispatchToken = Dispatcher.register((payload) => {
switch(payload.constructor) {
case SignInSuccess:
this.currentUser = payload.newUser;
this.emit(“change”);
}
});
}
class UserStore extends GriffinStore {
reducer(state = null, action) => {
switch(action.constructor) {
case SignInSuccess:
return payload.newUser;
default:
return state;
}
});
}
function getState() {
return { currentUser: UserStore.currentUser }
}
class SignInComponent extends React.Component {
state = getState();
handleStateChange() { this.setState(getState()); }
componentDidMount() { UserStore.on(“change”, this.handleStateChange); }
componentWillUnmount() {
UserStore.removeListener(“change”, this.handleStateChange);
}
handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your
password?”)); }
render() {
if(!this.state.currentUser)
return <a onClick={this.handleAuth}>Click here to sign in</a>;
else
return <p>You’re signed in as {this.state.currentUser.name}</p>;
}
}
@connect({ currentUser: UserStore })
class SignInComponent extends React.Component {
handleAuth(event) { signInUser(prompt(“What’s your
username?”), prompt(“What’s your password?”)); }
render() {
if(!this.props.currentUser)
return <a onClick={this.handleAuth}>Click here to
sign in</a>;
else
return <p>You’re signed in as
{this.props.currentUser.name}</p>;
}
}
R E A C T D E P E N D E N C Y I N J E C T I O N
• Using props to pass in external data is similar to Angular’s dependency
injection
• Only use state to manage internal component state
• <SignInComponent currentUser={{name: “Mock User!”}} />
• <SignInComponent currentUser={null} />
R E A C T R O U T E R
R E A C T R O U T E R
• Amazing routing solution - Inspired heavily by Ember’s router
• Ember has an excellent router
• Uses JSX or JSON to describe routes and nested routes
• React Component will be loaded by a Route
• Version 1.0 has lazy loading of routes and components
• Better Server Side Rendering
React.render((
<Router>
<Route path="/" component={App}>
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
<Route path="messages/:id"
component={Message} />
</Route>
</Route>
</Router>
), document.body)
.
├── AppComponent.js => /
├── AboutComponent.js => /about
├── InboxComponent.js => /inbox
└── MessageComponent.js => /inbox/messages/:id
.
├── AppComponent.js => /
├── AboutComponent.js => /about
├── InboxComponent.js => /inbox
└── inbox
   └── MessageComponent.js => /inbox/messages/:id
.
├── index.js => /
├── about
│   └── index.js => /about
└── inbox
   ├── index.js => /inbox
   └── messages
   └── @id
   └── index.js => /inbox/messages/:id
.
├── index.js => /
├── about
│   └── index.js => /about
└── inbox
   ├── DeleteMessage.js
   ├── GetMessages.js
   ├── MessageStore.js
   ├── index.js => /inbox
   └── messages
   └── @id
   └── index.js => /inbox/messages/:id
React.render((
<Router>
<Route path="/" component={App}>
<Route path="about" component={About} />
<Route path="inbox" component={Inbox}>
<Route path="messages/:id"
component={Message} />
</Route>
</Route>
</Router>
), document.body)
G R I F F I N F I L E S Y S T E M B A S E D R O U T I N G
• Easy to initialize your app
• import myApp from “griffin!.”;

myApp({ /* any griffin options here */});
• Easy to mount other apps
• import anotherApp from “griffin!/path/to/app”;

anotherApp({ /* griffin options */});
U N I V E R S A L A P P S W I T H W E B PA C K
• Everything goes through WebPack
• Based on James Long’s excellent “Backend Apps with WebPack” posts
• On the server, it ignores CSS, images, etc.
• WebPack enables lazy-loading of application chunks
• Incrementally load Griffin routes
• Include common modules with initial payload
G R I F F I N . J S S TAT U S
• Almost ready for release
• Planning to release in the next few months
• I’m currently rewriting the WebPack incremental file-system based routing
• Last core item remaining before release
0
100
Number of times you’ve built a similar app
1 2 3 4 5 6 7 ...
Quality
Mistakes Made
T H A N K Y O U
@ t a z s i n g h

Mais conteúdo relacionado

Mais procurados

Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
Yehuda Katz
 
JSON Rules Language
JSON Rules LanguageJSON Rules Language
JSON Rules Language
giurca
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
dmethvin
 
JavaScript Testing for Rubyists
JavaScript Testing for RubyistsJavaScript Testing for Rubyists
JavaScript Testing for Rubyists
Jamie Dyer
 
React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes sense
Eldar Djafarov
 

Mais procurados (20)

Integrating React.js with PHP projects
Integrating React.js with PHP projectsIntegrating React.js with PHP projects
Integrating React.js with PHP projects
 
ReactJS
ReactJSReactJS
ReactJS
 
Kakunin E2E framework showcase
Kakunin E2E framework showcaseKakunin E2E framework showcase
Kakunin E2E framework showcase
 
Introduction to ReactJS and Redux
Introduction to ReactJS and ReduxIntroduction to ReactJS and Redux
Introduction to ReactJS and Redux
 
Reduxing like a pro
Reduxing like a proReduxing like a pro
Reduxing like a pro
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
JSON Rules Language
JSON Rules LanguageJSON Rules Language
JSON Rules Language
 
React with Redux
React with ReduxReact with Redux
React with Redux
 
jQuery in 15 minutes
jQuery in 15 minutesjQuery in 15 minutes
jQuery in 15 minutes
 
Extending Redux in the Server Side
Extending Redux in the Server SideExtending Redux in the Server Side
Extending Redux in the Server Side
 
Angular Tutorial Freshers and Experienced
Angular Tutorial Freshers and ExperiencedAngular Tutorial Freshers and Experienced
Angular Tutorial Freshers and Experienced
 
amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5amsterdamjs - jQuery 1.5
amsterdamjs - jQuery 1.5
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
 
Take My Logs. Please!
Take My Logs. Please!Take My Logs. Please!
Take My Logs. Please!
 
Frontin like-a-backer
Frontin like-a-backerFrontin like-a-backer
Frontin like-a-backer
 
Ditching JQuery
Ditching JQueryDitching JQuery
Ditching JQuery
 
JavaScript Testing for Rubyists
JavaScript Testing for RubyistsJavaScript Testing for Rubyists
JavaScript Testing for Rubyists
 
React.js or why DOM finally makes sense
React.js or why DOM finally makes senseReact.js or why DOM finally makes sense
React.js or why DOM finally makes sense
 
High Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScriptHigh Performance web apps in Om, React and ClojureScript
High Performance web apps in Om, React and ClojureScript
 
JavaScript Promise
JavaScript PromiseJavaScript Promise
JavaScript Promise
 

Destaque

Reinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative HackathonsReinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative Hackathons
FITC
 
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig FitzpatrickPageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
FITC
 
The Shifting Nature of FED Role
The Shifting Nature of FED RoleThe Shifting Nature of FED Role
The Shifting Nature of FED Role
FITC
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 
Fitc whats new in es6 for web devs
Fitc   whats new in es6 for web devsFitc   whats new in es6 for web devs
Fitc whats new in es6 for web devs
FITC
 

Destaque (20)

The Working Dead
The Working DeadThe Working Dead
The Working Dead
 
Creating a Smile Worthy World
Creating a Smile Worthy WorldCreating a Smile Worthy World
Creating a Smile Worthy World
 
Your UX is not my UX
Your UX is not my UXYour UX is not my UX
Your UX is not my UX
 
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric BoydGamify Your Life – My Epic Quest of Awesome - Eric Boyd
Gamify Your Life – My Epic Quest of Awesome - Eric Boyd
 
Reinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative HackathonsReinvent Your Creative Process with Collaborative Hackathons
Reinvent Your Creative Process with Collaborative Hackathons
 
A New Era for Animators
A New Era for AnimatorsA New Era for Animators
A New Era for Animators
 
Design to the Future
Design to the FutureDesign to the Future
Design to the Future
 
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig FitzpatrickPageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
PageCloud Reimagines The Future of Website Creation with Craig Fitzpatrick
 
The Shifting Nature of FED Role
The Shifting Nature of FED RoleThe Shifting Nature of FED Role
The Shifting Nature of FED Role
 
Getting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own PluginGetting to Know Grunt By Writing Your Own Plugin
Getting to Know Grunt By Writing Your Own Plugin
 
(Re)aligning The Way 400,000 People Think
(Re)aligning The Way 400,000 People Think(Re)aligning The Way 400,000 People Think
(Re)aligning The Way 400,000 People Think
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
 
Open Sourcing the Secret Sauce
Open Sourcing the Secret SauceOpen Sourcing the Secret Sauce
Open Sourcing the Secret Sauce
 
Fitc whats new in es6 for web devs
Fitc   whats new in es6 for web devsFitc   whats new in es6 for web devs
Fitc whats new in es6 for web devs
 
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
Upgrading the Web with Douglas Crockford @ FITC's Web Unleashed 2015
 
Embedding Cognitive Innovation in Design
Embedding Cognitive Innovation in DesignEmbedding Cognitive Innovation in Design
Embedding Cognitive Innovation in Design
 
Graphic Designer to Object Designer: Your 3D Printing Evolution
Graphic Designer to Object Designer: Your 3D Printing EvolutionGraphic Designer to Object Designer: Your 3D Printing Evolution
Graphic Designer to Object Designer: Your 3D Printing Evolution
 
The Future is in Pieces
The Future is in PiecesThe Future is in Pieces
The Future is in Pieces
 
Front-end Tools: Sifting Through the Madness
 Front-end Tools: Sifting Through the Madness Front-end Tools: Sifting Through the Madness
Front-end Tools: Sifting Through the Madness
 
The Giddiest Kipper
The Giddiest KipperThe Giddiest Kipper
The Giddiest Kipper
 

Semelhante a A Journey with React

Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
Skills Matter
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
Mike Subelsky
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
Chris Alfano
 

Semelhante a A Journey with React (20)

Chris Wilson: Progressive Web Apps
Chris Wilson: Progressive Web AppsChris Wilson: Progressive Web Apps
Chris Wilson: Progressive Web Apps
 
Using ReasonML For Your Next JavaScript Project
Using ReasonML For Your Next JavaScript ProjectUsing ReasonML For Your Next JavaScript Project
Using ReasonML For Your Next JavaScript Project
 
Progressive Enhancement for JavaScript Apps
Progressive Enhancement for JavaScript AppsProgressive Enhancement for JavaScript Apps
Progressive Enhancement for JavaScript Apps
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
Week 8
Week 8Week 8
Week 8
 
N Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React NativeN Things You Don't Want to Repeat in React Native
N Things You Don't Want to Repeat in React Native
 
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
The Return of JavaScript: 3 Open-Source Projects that are driving JavaScript'...
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Primefaces Nextgen Lju
Primefaces Nextgen LjuPrimefaces Nextgen Lju
Primefaces Nextgen Lju
 
Metrics-Driven Engineering
Metrics-Driven EngineeringMetrics-Driven Engineering
Metrics-Driven Engineering
 
Using React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIsUsing React, Redux and Saga with Lottoland APIs
Using React, Redux and Saga with Lottoland APIs
 
Gmaps Railscamp2008
Gmaps Railscamp2008Gmaps Railscamp2008
Gmaps Railscamp2008
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Plone Interactivity
Plone InteractivityPlone Interactivity
Plone Interactivity
 
Advanced React Component Patterns - ReactNext 2018
Advanced React Component Patterns - ReactNext 2018Advanced React Component Patterns - ReactNext 2018
Advanced React Component Patterns - ReactNext 2018
 
Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016Async Redux Actions With RxJS - React Rally 2016
Async Redux Actions With RxJS - React Rally 2016
 
Implementation of GUI Framework part3
Implementation of GUI Framework part3Implementation of GUI Framework part3
Implementation of GUI Framework part3
 
Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011Jarv.us Showcase — SenchaCon 2011
Jarv.us Showcase — SenchaCon 2011
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
Serverless Functions and Vue.js
Serverless Functions and Vue.jsServerless Functions and Vue.js
Serverless Functions and Vue.js
 

Mais de FITC

Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
FITC
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
FITC
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
FITC
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
FITC
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
FITC
 

Mais de FITC (20)

Cut it up
Cut it upCut it up
Cut it up
 
Designing for Digital Health
Designing for Digital HealthDesigning for Digital Health
Designing for Digital Health
 
Profiling JavaScript Performance
Profiling JavaScript PerformanceProfiling JavaScript Performance
Profiling JavaScript Performance
 
Surviving Your Tech Stack
Surviving Your Tech StackSurviving Your Tech Stack
Surviving Your Tech Stack
 
How to Pitch Your First AR Project
How to Pitch Your First AR ProjectHow to Pitch Your First AR Project
How to Pitch Your First AR Project
 
Start by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the AnswerStart by Understanding the Problem, Not by Delivering the Answer
Start by Understanding the Problem, Not by Delivering the Answer
 
Cocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s StoryCocaine to Carrots: The Art of Telling Someone Else’s Story
Cocaine to Carrots: The Art of Telling Someone Else’s Story
 
Everyday Innovation
Everyday InnovationEveryday Innovation
Everyday Innovation
 
HyperLight Websites
HyperLight WebsitesHyperLight Websites
HyperLight Websites
 
Everything is Terrifying
Everything is TerrifyingEverything is Terrifying
Everything is Terrifying
 
Post-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future HumanPost-Earth Visions: Designing for Space and the Future Human
Post-Earth Visions: Designing for Space and the Future Human
 
The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)The Rise of the Creative Social Influencer (and How to Become One)
The Rise of the Creative Social Influencer (and How to Become One)
 
East of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR GameEast of the Rockies: Developing an AR Game
East of the Rockies: Developing an AR Game
 
Creating a Proactive Healthcare System
Creating a Proactive Healthcare SystemCreating a Proactive Healthcare System
Creating a Proactive Healthcare System
 
World Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product DesignWorld Transformation: The Secret Agenda of Product Design
World Transformation: The Secret Agenda of Product Design
 
The Power of Now
The Power of NowThe Power of Now
The Power of Now
 
High Performance PWAs
High Performance PWAsHigh Performance PWAs
High Performance PWAs
 
Rise of the JAMstack
Rise of the JAMstackRise of the JAMstack
Rise of the JAMstack
 
From Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self DiscoveryFrom Closed to Open: A Journey of Self Discovery
From Closed to Open: A Journey of Self Discovery
 
Projects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time ForProjects Ain’t Nobody Got Time For
Projects Ain’t Nobody Got Time For
 

Último

Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Chandigarh Call girls 9053900678 Call girls in Chandigarh
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
@Chandigarh #call #Girls 9053900678 @Call #Girls in @Punjab 9053900678
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Sheetaleventcompany
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
sexy call girls service in goa
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
Diya Sharma
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 

Último (20)

Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Rani Bagh Escort Service Delhi N.C.R.
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
Low Sexy Call Girls In Mohali 9053900678 🥵Have Save And Good Place 🥵
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
6.High Profile Call Girls In Punjab +919053900678 Punjab Call GirlHigh Profil...
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
VIP Model Call Girls NIBM ( Pune ) Call ON 8005736733 Starting From 5K to 25K...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
2nd Solid Symposium: Solid Pods vs Personal Knowledge Graphs
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine ServiceHot Service (+9316020077 ) Goa  Call Girls Real Photos and Genuine Service
Hot Service (+9316020077 ) Goa Call Girls Real Photos and Genuine Service
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark WebGDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
GDG Cloud Southlake 32: Kyle Hettinger: Demystifying the Dark Web
 
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Dlf City Phase 3 Gurgaon >༒8448380779 Escort Service
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 

A Journey with React

  • 1. A J O U R N E Y W I T H R E A C T TA S V E E R S I N G H @ t a z s i n g h
  • 2.
  • 3.
  • 4.
  • 5. 3 A P P S
  • 6. – M I K E H O U R A H I N E “You can learn trigonometry, physics, C++, and DirectX to make a video game. Or you can make a video game and learn DirectX, C++, physics, and trigonometry.”
  • 7. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 8. A P P # 1 - R E A C T A S A T E M P L AT I N G E N G I N E • Server side application framework • Nashorn JavaScript engine for Java 8 • Vert.x 2.3 - Polyglot Event-Driven Messaging • Innovative Router • React to describe HTML
  • 9. A P P # 2 - F L U X
  • 10.
  • 11.
  • 12.
  • 15.
  • 16. A P P # 2 - F L U X • My first iteration relied on my experience from MVC • Business logic resides in Models/Stores • Fat models, skinny controllers • Models/Stores make AJAX calls • Actions were very light weight notifications to the Stores
  • 17. function signInUser(username, password) { Dispatcher.dispatch({ type: ActionTypes.USER_SIGN_IN , username: username , password: password }); }
  • 18. class UserStore extends EventEmitter { currentUser = null; dispatchToken = Dispatcher.register((action) => { switch(action.type) { case ActionTypes.USER_SIGN_IN: fetchUser(action.username, action.password).then( (response) => { this.currentUser = response.user; this.emit(“change”); }); } }); }
  • 19. function getState() { return { currentUser: UserStore.currentUser } } class SignInComponent extends React.Component { state = getState(); handleStateChange() { this.setState(getState()); } componentDidMount() { UserStore.on(“change”, this.handleStateChange); } componentWillUnmount() { UserStore.removeListener(“change”, this.handleStateChange); } handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your password?”)); } render() { if(!this.state.currentUser) return <a onClick={this.handleAuth}>Click here to sign in</a>; else return <p>You’re signed in as {this.state.currentUser.name}</p>; } }
  • 20. A P P # 2 - F L U X - F I R S T I T E R AT I O N • Facebook’s Dispatcher does not allow you to dispatch from a dispatch • Difficult to compose application flow • How do you handle errors? • Relies on the Global State of ActionTypes • Views worked great!
  • 21. N E X T I T E R AT I O N T RY C O M P O S I N G A C T I O N S
  • 22. class SignInUser extends BaseAction { constructor(username, password, alreadySignedInUser) { this.username = username; this.password = password; this.alreadySignedInUser = alreadySignedInUser; if(!this.alreadySignedInUser) this.authUser(); } authUser() { fetchUser(this.username, this.password).then( (newUser) => { new SignInSuccess(newUser); } , (errors) => { new SignInFailure(errors); } ); }
  • 23.
  • 24. class SignInUser extends BaseAction { constructor(username, password, alreadySignedInUser) { this.username = username; this.password = password; this.alreadySignedInUser = alreadySignedInUser; if(!this.alreadySignedInUser) this.authUser(); } authUser() { fetchUser(this.username, this.password).then( (newUser) => { new SignInSuccess(newUser); } , (errors) => { new SignInFailure(errors); } ); }
  • 25. class SignInSuccess extends BaseAction { constructor(newUser) { this.newUser = newUser; this.dispatch(); } } class SignInFailure extends BaseAction { constructor(errors) { this.errors = errors; this.dispatch(); new FlashMessage(“Could not sign in”); } }
  • 26. class UserStore extends EventEmitter { currentUser = null; dispatchToken = Dispatcher.register((action) => { switch(action.constructor) { case SignInSuccess: this.currentUser = action.newUser; this.emit(“change”); } }); }
  • 27. A P P # 2 - F L U X - 2 N D I T E R AT I O N • Eliminates the “dispatching from a dispatch” problem • Stores are synchronous • Very easy to compose the flow of your application by composing actions • Eliminated Global State of ActionTypes • Extremely scalable solution • Easy to test • In a later iteration, dropped in WebPack
  • 28. A P P # 3 - B R O C H U R E W E B S I T E
  • 29. A P P # 3 - B R O C H U R E W E B S I T E • SEO is paramount • AJAX is bad for SEO • Performant on Desktop and Mobile • Server Side Rendered • Incremental Loading • Introduce server side developers to client side technologies • ES6/ES2015 via Babel • React + Flux + WebPack
  • 30. A P P # 3 - B R O C H U R E W E B S I T E • Server side React + Server side Flux • WebPack manages front end assets, inlining, and chunking • Incremental loading by chunking • Reduce number of web requests by inlining • Koa.js serves the application and handles routing
  • 31. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 32. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 33. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 34.
  • 35. G R I F F I N . J S
  • 36. G R I F F I N . J S • Includes everything I’ve learnt and more • Facebook’s Dispatcher • React Views • Griffin Actions - Same as previous examples • Redux Stores w/ Griffin Connector to Views
  • 37. class UserStore extends EventEmitter { currentUser = null; dispatchToken = Dispatcher.register((payload) => { switch(payload.constructor) { case SignInSuccess: this.currentUser = payload.newUser; this.emit(“change”); } }); }
  • 38. class UserStore extends GriffinStore { reducer(state = null, action) => { switch(action.constructor) { case SignInSuccess: return payload.newUser; default: return state; } }); }
  • 39. function getState() { return { currentUser: UserStore.currentUser } } class SignInComponent extends React.Component { state = getState(); handleStateChange() { this.setState(getState()); } componentDidMount() { UserStore.on(“change”, this.handleStateChange); } componentWillUnmount() { UserStore.removeListener(“change”, this.handleStateChange); } handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your password?”)); } render() { if(!this.state.currentUser) return <a onClick={this.handleAuth}>Click here to sign in</a>; else return <p>You’re signed in as {this.state.currentUser.name}</p>; } }
  • 40. @connect({ currentUser: UserStore }) class SignInComponent extends React.Component { handleAuth(event) { signInUser(prompt(“What’s your username?”), prompt(“What’s your password?”)); } render() { if(!this.props.currentUser) return <a onClick={this.handleAuth}>Click here to sign in</a>; else return <p>You’re signed in as {this.props.currentUser.name}</p>; } }
  • 41. R E A C T D E P E N D E N C Y I N J E C T I O N • Using props to pass in external data is similar to Angular’s dependency injection • Only use state to manage internal component state • <SignInComponent currentUser={{name: “Mock User!”}} /> • <SignInComponent currentUser={null} />
  • 42. R E A C T R O U T E R
  • 43. R E A C T R O U T E R • Amazing routing solution - Inspired heavily by Ember’s router • Ember has an excellent router • Uses JSX or JSON to describe routes and nested routes • React Component will be loaded by a Route • Version 1.0 has lazy loading of routes and components • Better Server Side Rendering
  • 44. React.render(( <Router> <Route path="/" component={App}> <Route path="about" component={About} /> <Route path="inbox" component={Inbox}> <Route path="messages/:id" component={Message} /> </Route> </Route> </Router> ), document.body)
  • 45. . ├── AppComponent.js => / ├── AboutComponent.js => /about ├── InboxComponent.js => /inbox └── MessageComponent.js => /inbox/messages/:id
  • 46. . ├── AppComponent.js => / ├── AboutComponent.js => /about ├── InboxComponent.js => /inbox └── inbox    └── MessageComponent.js => /inbox/messages/:id
  • 47. . ├── index.js => / ├── about │   └── index.js => /about └── inbox    ├── index.js => /inbox    └── messages    └── @id    └── index.js => /inbox/messages/:id
  • 48. . ├── index.js => / ├── about │   └── index.js => /about └── inbox    ├── DeleteMessage.js    ├── GetMessages.js    ├── MessageStore.js    ├── index.js => /inbox    └── messages    └── @id    └── index.js => /inbox/messages/:id
  • 49. React.render(( <Router> <Route path="/" component={App}> <Route path="about" component={About} /> <Route path="inbox" component={Inbox}> <Route path="messages/:id" component={Message} /> </Route> </Route> </Router> ), document.body)
  • 50. G R I F F I N F I L E S Y S T E M B A S E D R O U T I N G • Easy to initialize your app • import myApp from “griffin!.”;
 myApp({ /* any griffin options here */}); • Easy to mount other apps • import anotherApp from “griffin!/path/to/app”;
 anotherApp({ /* griffin options */});
  • 51. U N I V E R S A L A P P S W I T H W E B PA C K • Everything goes through WebPack • Based on James Long’s excellent “Backend Apps with WebPack” posts • On the server, it ignores CSS, images, etc. • WebPack enables lazy-loading of application chunks • Incrementally load Griffin routes • Include common modules with initial payload
  • 52. G R I F F I N . J S S TAT U S • Almost ready for release • Planning to release in the next few months • I’m currently rewriting the WebPack incremental file-system based routing • Last core item remaining before release
  • 53. 0 100 Number of times you’ve built a similar app 1 2 3 4 5 6 7 ... Quality Mistakes Made
  • 54. T H A N K Y O U @ t a z s i n g h