Top Banner
React, Flux, and Realtime RSVPs April 18, 2016 - KnoxJS Alex Klibisz
20

React, Flux, and Realtime RSVPs

Apr 15, 2017

Download

Technology

Alex Klibisz
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: React, Flux, and Realtime RSVPs

React, Flux, and Realtime RSVPsApril 18, 2016 - KnoxJS

Alex Klibisz

Page 2: React, Flux, and Realtime RSVPs

Thanks to...

Page 3: React, Flux, and Realtime RSVPs

Alex Klibisz (Kleebeesh)

- Senior at UT, Computer Science- Web development background- Node.js, Angular, Knockout, jQuery, Cordova, since late 2014.- Started using React September 2015.

Page 4: React, Flux, and Realtime RSVPs

Contents

1. React2. Flux3. What are we building?4. Why React?5. Strategy6. Build it!

Page 5: React, Flux, and Realtime RSVPs

React

- Library for component-based views- Rendering, updating, handling interactions in components- Often used with multiple other tools

Page 6: React, Flux, and Realtime RSVPs

React (example)

Component is given props

Component declares what to display

React renders component

Component re-renderedautomatically on changes.

● Simon● Alvin● Theo

● Sam● Alex● Chris

Page 7: React, Flux, and Realtime RSVPs

Why’s that helpful

1. Treat components as functions.2. Re-use and compose components.3. Render to a virtual DOM, React applies minimal change to real DOM.4. Node.js-style modules and npm for dependencies.5. Render on the server (good for SEO, social sharing, etc.)

Page 8: React, Flux, and Realtime RSVPs

Flux

- Pattern for maintaining data in your app- Many implementations (Alt, Redux, Reflux, etc.)- Stores: store the data- Actions: update the data- Components: subscribe to updates

Page 9: React, Flux, and Realtime RSVPs

Flux (example)

UserStore.users = [“Simon”, “Alvin”, “Theo”]

UserList UserAddUserGallery

UserActions.addUser(“Alex”)

UserActions.addUser(“Sam”)

Stores contain shared data.

Components subscribe to stores.

Components update stores via actions.

Page 10: React, Flux, and Realtime RSVPs

Why’s that helpful

1. Source of truth for your application’s state.2. Easy to sync data across components.

Page 11: React, Flux, and Realtime RSVPs

Confusion is Normal

1. Build systems (Webpack, Browserify, etc.)2. ES6, ES7 is the norm3. Careful with “boilerplates” and “starter projects”4. Plenty of online banter

Page 12: React, Flux, and Realtime RSVPs

What are we building?

- Real-time RSVPs from Meetup.com over a websocket.- Bar charts using NVD3- World map with pins using Leaflet

Page 13: React, Flux, and Realtime RSVPs

Why React and Flux?

1. Re-usable components2. Re-rendering in real-time3. Single source of data, multiple components

Page 14: React, Flux, and Realtime RSVPs

Dashboard

Strategy: Component Structure

MapViz

ChartViz

ChartViz

ChartViz

Footer

Header

Page 15: React, Flux, and Realtime RSVPs

Strategy: Component APIs

Page 16: React, Flux, and Realtime RSVPs

Strategy: Data Flow

Meetup.com RSVP API

socket.onmessage = MeetupActions.addRSVP

websocket

MeetupStore.onAddRSVP

RSVP

RSVP

Dashboard

MapViz ChartViz (x3) Footer

RSVPRSVPRSVPRSVP

count countries last names states

Subscribe to updates

Page 17: React, Flux, and Realtime RSVPs

Code time...

Page 18: React, Flux, and Realtime RSVPs

VoteForAlex.xyz

1. Exploring AWS Lambda and Serverless Architectures2. Firebase: architecting beyond the chat app

Page 19: React, Flux, and Realtime RSVPs

Thanks to...

Page 20: React, Flux, and Realtime RSVPs

React, Flux, and Realtime RSVPsSlides and code @ alex.klibisz.com

tw: @alexklibisz email: [email protected]