+ All Categories
Home > Software > Using React/Redux to build a chat system.

Using React/Redux to build a chat system.

Date post: 16-Apr-2017
Category:
Upload: jim-liu
View: 499 times
Download: 0 times
Share this document with a friend
30
Supplyfx Chat
Transcript
Page 1: Using React/Redux to build a chat system.

Supplyfx Chat

Page 2: Using React/Redux to build a chat system.

What’s React

State

Properties

JSX virtual DOM

+Render

diff

DOM

Page 3: Using React/Redux to build a chat system.

https://facebook.github.io/react/

class Timer extends React.Component {

Page 4: Using React/Redux to build a chat system.
Page 5: Using React/Redux to build a chat system.

Flux

Page 6: Using React/Redux to build a chat system.

Redux is "Flux-like"

Single Source of Truth

State is Read-Only

Changes are made with Pure Functions

Page 7: Using React/Redux to build a chat system.

Redux

Page 8: Using React/Redux to build a chat system.

Data Flow

WebAPI Socket

AJAX Request Socket Client Actions Reducer

StoreView

Page 9: Using React/Redux to build a chat system.
Page 10: Using React/Redux to build a chat system.

State + Components

Page 11: Using React/Redux to build a chat system.

Chat Components

Page 12: Using React/Redux to build a chat system.
Page 13: Using React/Redux to build a chat system.
Page 14: Using React/Redux to build a chat system.

Sidebarconversations = [ { name: ‘FE’, description: ‘every day ….’, imageUrl: ‘…’, lastMessageAt: 123456, lastMessageSummary: ‘…’ }, {…}, …

]

Page 15: Using React/Redux to build a chat system.

Sidebar with filterconversations = conversations.filter(c => c.name.indexOf(keyword) !== -1);

Page 16: Using React/Redux to build a chat system.

Conversation

Page 17: Using React/Redux to build a chat system.

User

Page 18: Using React/Redux to build a chat system.

State

Page 19: Using React/Redux to build a chat system.

popovers

messages

users rooms

read states

participants

requests

conversations requests

dialog

image viewer

composer

header

sidebar preferences

connection

router

app

Page 20: Using React/Redux to build a chat system.

Reducers

Page 21: Using React/Redux to build a chat system.

Init

socket.io Server

socket.io client

init action

users

rooms

conversations

reducers

Page 22: Using React/Redux to build a chat system.

new message

socket.io Server

socket.io client

new-msg action

messages

read states

conversations

reducers

Page 23: Using React/Redux to build a chat system.

load messages

socket.io Server

socket.io client

msgs loaded

messages

conversations

reducers

socket.io client

Page 24: Using React/Redux to build a chat system.

Selectors

Page 25: Using React/Redux to build a chat system.

Sidebar

users

rooms

read states

conversations

sidebar

router

filter

sort

combine

conversations

Page 26: Using React/Redux to build a chat system.

Conversation

users

rooms

conversationsfind by router

combine

conversation

router

participants

requests

Page 27: Using React/Redux to build a chat system.

Supplyfx Chat

actions: are payloads of information that send data to the store.

components: React components that are driven solely by props and don't talk to Redux.

constants: Like actionTypes, storage keys

containers: React components that are aware of Redux, Router, etc.

Page 28: Using React/Redux to build a chat system.

Supplyfx Chat

lib: utility code, helpers

records: Immutable Records, like Models

reducers: Redux reducers, response for the actions, splitting the state to slices.

selectors: memorized, composable selector functions

store: create store for redux application.

Page 29: Using React/Redux to build a chat system.

Q & A

Page 30: Using React/Redux to build a chat system.

References

https://facebook.github.io/react/

http://redux.js.org/

https://facebook.github.io/immutable-js/

https://css-tricks.com/learning-react-redux/

https://code-cartoons.com/a-cartoon-intro-to-redux-3afb775501a6#.cmkxw64bq


Recommended