Suche senden
Hochladen
React. Redux. Real world.
•
Als PPTX, PDF herunterladen
•
1 gefällt mir
•
277 views
Rost Galkin
Folgen
Our SPA development experience in BABO with React and Redux
Weniger lesen
Mehr lesen
Software
Melden
Teilen
Melden
Teilen
1 von 53
Jetzt herunterladen
Empfohlen
如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test
名辰 洪
Concurrent applications with free monads and stm
Concurrent applications with free monads and stm
Alexander Granin
The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202
Mahmoud Samir Fayed
The Ring programming language version 1.5.1 book - Part 53 of 180
The Ring programming language version 1.5.1 book - Part 53 of 180
Mahmoud Samir Fayed
Universal JavaScript
Universal JavaScript
名辰 洪
The Ring programming language version 1.10 book - Part 66 of 212
The Ring programming language version 1.10 book - Part 66 of 212
Mahmoud Samir Fayed
Travel management
Travel management
1Parimal2
SOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean Architecture
Fabio Collini
Empfohlen
如何「畫圖」寫測試 - RxJS Marble Test
如何「畫圖」寫測試 - RxJS Marble Test
名辰 洪
Concurrent applications with free monads and stm
Concurrent applications with free monads and stm
Alexander Granin
The Ring programming language version 1.8 book - Part 61 of 202
The Ring programming language version 1.8 book - Part 61 of 202
Mahmoud Samir Fayed
The Ring programming language version 1.5.1 book - Part 53 of 180
The Ring programming language version 1.5.1 book - Part 53 of 180
Mahmoud Samir Fayed
Universal JavaScript
Universal JavaScript
名辰 洪
The Ring programming language version 1.10 book - Part 66 of 212
The Ring programming language version 1.10 book - Part 66 of 212
Mahmoud Samir Fayed
Travel management
Travel management
1Parimal2
SOLID principles in practice: the Clean Architecture
SOLID principles in practice: the Clean Architecture
Fabio Collini
Bangun datar dan bangun ruang
Bangun datar dan bangun ruang
SanSan Yagyoo
CoffeeScript
CoffeeScript
Mark
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
Sergey Platonov
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202
Mahmoud Samir Fayed
662305 11
662305 11
Nitigan Nakjuatong
The Ring programming language version 1.8 book - Part 65 of 202
The Ring programming language version 1.8 book - Part 65 of 202
Mahmoud Samir Fayed
The Ring programming language version 1.9 book - Part 64 of 210
The Ring programming language version 1.9 book - Part 64 of 210
Mahmoud Samir Fayed
กลุ่ม6
กลุ่ม6
Witita Khamsook
Mutation Testing - Voxxed Days Bucharest 10.03.2017
Mutation Testing - Voxxed Days Bucharest 10.03.2017
Rafał Leszko
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
Mahmoud Samir Fayed
OpenGL L06-Performance
OpenGL L06-Performance
Mohammad Shaker
The Ring programming language version 1.8 book - Part 73 of 202
The Ring programming language version 1.8 book - Part 73 of 202
Mahmoud Samir Fayed
OpenGL Starter L02
OpenGL Starter L02
Mohammad Shaker
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
Mahmoud Samir Fayed
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
DeNA
The Ring programming language version 1.6 book - Part 86 of 189
The Ring programming language version 1.6 book - Part 86 of 189
Mahmoud Samir Fayed
The Ring programming language version 1.10 book - Part 68 of 212
The Ring programming language version 1.10 book - Part 68 of 212
Mahmoud Samir Fayed
Exploring Color Spaces with Gesture Tracking and Smart Bulbs (Distill 2014)
Exploring Color Spaces with Gesture Tracking and Smart Bulbs (Distill 2014)
Daniel Luxemburg
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
Mahmoud Samir Fayed
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
GlobalLogic Ukraine
Side effects-con-redux
Side effects-con-redux
Nicolas Quiceno Benavides
React, Redux and es6/7
React, Redux and es6/7
Dongho Cho
Weitere ähnliche Inhalte
Was ist angesagt?
Bangun datar dan bangun ruang
Bangun datar dan bangun ruang
SanSan Yagyoo
CoffeeScript
CoffeeScript
Mark
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
Sergey Platonov
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202
Mahmoud Samir Fayed
662305 11
662305 11
Nitigan Nakjuatong
The Ring programming language version 1.8 book - Part 65 of 202
The Ring programming language version 1.8 book - Part 65 of 202
Mahmoud Samir Fayed
The Ring programming language version 1.9 book - Part 64 of 210
The Ring programming language version 1.9 book - Part 64 of 210
Mahmoud Samir Fayed
กลุ่ม6
กลุ่ม6
Witita Khamsook
Mutation Testing - Voxxed Days Bucharest 10.03.2017
Mutation Testing - Voxxed Days Bucharest 10.03.2017
Rafał Leszko
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
Mahmoud Samir Fayed
OpenGL L06-Performance
OpenGL L06-Performance
Mohammad Shaker
The Ring programming language version 1.8 book - Part 73 of 202
The Ring programming language version 1.8 book - Part 73 of 202
Mahmoud Samir Fayed
OpenGL Starter L02
OpenGL Starter L02
Mohammad Shaker
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
Mahmoud Samir Fayed
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
DeNA
The Ring programming language version 1.6 book - Part 86 of 189
The Ring programming language version 1.6 book - Part 86 of 189
Mahmoud Samir Fayed
The Ring programming language version 1.10 book - Part 68 of 212
The Ring programming language version 1.10 book - Part 68 of 212
Mahmoud Samir Fayed
Exploring Color Spaces with Gesture Tracking and Smart Bulbs (Distill 2014)
Exploring Color Spaces with Gesture Tracking and Smart Bulbs (Distill 2014)
Daniel Luxemburg
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
Mahmoud Samir Fayed
Was ist angesagt?
(19)
Bangun datar dan bangun ruang
Bangun datar dan bangun ruang
CoffeeScript
CoffeeScript
Михаил Матросов, Повседневный С++: boost и STL
Михаил Матросов, Повседневный С++: boost и STL
The Ring programming language version 1.8 book - Part 74 of 202
The Ring programming language version 1.8 book - Part 74 of 202
662305 11
662305 11
The Ring programming language version 1.8 book - Part 65 of 202
The Ring programming language version 1.8 book - Part 65 of 202
The Ring programming language version 1.9 book - Part 64 of 210
The Ring programming language version 1.9 book - Part 64 of 210
กลุ่ม6
กลุ่ม6
Mutation Testing - Voxxed Days Bucharest 10.03.2017
Mutation Testing - Voxxed Days Bucharest 10.03.2017
The Ring programming language version 1.7 book - Part 72 of 196
The Ring programming language version 1.7 book - Part 72 of 196
OpenGL L06-Performance
OpenGL L06-Performance
The Ring programming language version 1.8 book - Part 73 of 202
The Ring programming language version 1.8 book - Part 73 of 202
OpenGL Starter L02
OpenGL Starter L02
The Ring programming language version 1.5.4 book - Part 59 of 185
The Ring programming language version 1.5.4 book - Part 59 of 185
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
ヘルスケアサービスを実現する最新技術 〜HealthKit・GCP + Goの活用〜
The Ring programming language version 1.6 book - Part 86 of 189
The Ring programming language version 1.6 book - Part 86 of 189
The Ring programming language version 1.10 book - Part 68 of 212
The Ring programming language version 1.10 book - Part 68 of 212
Exploring Color Spaces with Gesture Tracking and Smart Bulbs (Distill 2014)
Exploring Color Spaces with Gesture Tracking and Smart Bulbs (Distill 2014)
The Ring programming language version 1.5.1 book - Part 64 of 180
The Ring programming language version 1.5.1 book - Part 64 of 180
Ähnlich wie React. Redux. Real world.
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
GlobalLogic Ukraine
Side effects-con-redux
Side effects-con-redux
Nicolas Quiceno Benavides
React, Redux and es6/7
React, Redux and es6/7
Dongho Cho
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
Florent Pillet
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & Couchbase
Alex Derkach
[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product
Igor Lozynskyi
React redux
React redux
Michel Perez
The evolution of redux action creators
The evolution of redux action creators
George Bukhanov
W-JAX 09 - Lift
W-JAX 09 - Lift
Heiko Seeberger
Compose Async with RxJS
Compose Async with RxJS
Kyung Yeol Kim
PyconKR 2018 Deep dive into Coroutine
PyconKR 2018 Deep dive into Coroutine
Daehee Kim
Redux for ReactJS Programmers
Redux for ReactJS Programmers
David Rodenas
Recoil at Codete Webinars #3
Recoil at Codete Webinars #3
Mateusz Bryła
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Ankara JUG
Job Queue in Golang
Job Queue in Golang
Bo-Yi Wu
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
Tsuyoshi Yamamoto
Prescribing RX Responsibly
Prescribing RX Responsibly
Nareg Khoshafian
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)
Takayuki Goto
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
Michiel Borkent
Cycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
Eugene Zharkov
Ähnlich wie React. Redux. Real world.
(20)
Using Redux-Saga for Handling Side Effects
Using Redux-Saga for Handling Side Effects
Side effects-con-redux
Side effects-con-redux
React, Redux and es6/7
React, Redux and es6/7
Reactive Programming Patterns with RxSwift
Reactive Programming Patterns with RxSwift
Bulding a reactive game engine with Spring 5 & Couchbase
Bulding a reactive game engine with Spring 5 & Couchbase
[JEEConf-2017] RxJava as a key component in mature Big Data product
[JEEConf-2017] RxJava as a key component in mature Big Data product
React redux
React redux
The evolution of redux action creators
The evolution of redux action creators
W-JAX 09 - Lift
W-JAX 09 - Lift
Compose Async with RxJS
Compose Async with RxJS
PyconKR 2018 Deep dive into Coroutine
PyconKR 2018 Deep dive into Coroutine
Redux for ReactJS Programmers
Redux for ReactJS Programmers
Recoil at Codete Webinars #3
Recoil at Codete Webinars #3
HTML5 - Daha Flash bir web?
HTML5 - Daha Flash bir web?
Job Queue in Golang
Job Queue in Golang
G*ワークショップ in 仙台 Grails(とことん)入門
G*ワークショップ in 仙台 Grails(とことん)入門
Prescribing RX Responsibly
Prescribing RX Responsibly
オープンデータを使ったモバイルアプリ開発(応用編)
オープンデータを使ったモバイルアプリ開発(応用編)
ClojureScript loves React, DomCode May 26 2015
ClojureScript loves React, DomCode May 26 2015
Cycle.js: Functional and Reactive
Cycle.js: Functional and Reactive
Kürzlich hochgeladen
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Steffen Staab
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
Wave PLM
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
kellynguyen01
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
ThousandEyes
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
kalichargn70th171
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
Andolasoft Inc
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Alberto González Trastoy
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
aagamshah0812
Software Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Arshad QA
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
MyIntelliSource, Inc.
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
ComplianceQuest1
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
ICS
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
Jhone kinadey
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
harshavardhanraghave
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
bodapatigopi8531
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
panagenda
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
SolGuruz
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
Kürzlich hochgeladen
(20)
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
Software Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
React. Redux. Real world.
1.
React.Redux.Real world. Rostislav (BABO)
2.
BABO 2
3.
3
4.
4
5.
5
6.
6
7.
FRONTEND 7
8.
Webpack React, Redux CSS Modules 8
9.
React 9
10.
Бесконечные списки Screen gif 10
11.
React-ingrid 11 Отображать только те
элементы, которые умещаются на экране
12.
Universal rendering const html
= ReactDOM.renderToString(<App data={data} />) res.send(html) 12 Блокирующий вызов
13.
Future React-dom-stream res.write(`<!DOCTYPE html>`) const stream
= ReactDOMStream.renderToStaticMarkup(<App data={data} />); stream.pipe(res) 13
14.
Redux 14
15.
DevTools, Logger, Time travelling15
16.
Простота 16
17.
Redux const reducer =
(oldState = `FOO`, action) => { switch(action.type) { case `UPDATE_FOO`: return `BAR` } return oldState } const store = createStore(reducer) 17 // подписаться на обновления store.subscribe(() => { assert.ok(store.getState() === `BAR`) }) // передать изменения store.dispatch({ type: `UPDATE_FOO` }) // получить текущее состояние assert.ok(store.getState() === `FOO`)
18.
Tests const reducer =
(oldState, action) => { switch(action.type) { case `ACTION_TYPE`: return action.payload } } assert.ok(reducer(``, `BAR`) === `BAR`) 18
19.
React + Redux <Provider
store={store}> <ButtonContainer /> </Provider> const Button = ({handleClick, title}) => ( <button onClick={handleClick}>{title}</button> ) 19 const mapStateToProps = state => ({ title: state.title }) const mapDispatchToProps = dispatch => ({ handleClick: () => dispatch({ type: `CLICK` }) }) const ButtonContainer = connect(mapStateToProps, mapDispatchToProps)(Button)
20.
Immutable 20
21.
spread... const initialState =
{ foo: `foo`, bar: `bar` } const reducer = (state = initialState, action) => { switch(action.type) { case `UPDATE_BAR`: return { ...state, bar: `baz` } } } return { ...state, we: { ...state.we, must: { ...state.we.must, go: { ...state.we.must.go, deeper: action.payload } } } } 21
22.
Immutable.js return { ...state, we: { ...state.we, must:
{ ...state.we.must, go: { ...state.we.must.go, deeper: action.payload } } } } return state.setIn([`we`, `must`, `go`, `deeper`], action.payload) 22
23.
Immutable.js const mapStateToProps =
state => ({ foo: state.get(`foo`), bar: state.get(`bar`), ... }) import { Map } from 'immutable' const map = Map({ foo: `bar` }) const { foo } = map assert.fails(foo === `bar`) assert.ok(foo === undefined) 23
24.
Seamless-immutable import Immutable from
'seamless-immutable' const map = Immutable({foo: `bar`}) const { foo } = map assert.ok(foo === `bar`) 24 Object.freeze() ~5 KB return state.setIn([`we`, `must`, `go`, `deeper`], action.payload)
25.
Расчеты 25
26.
26
27.
Вычисления const computeAction =
data => { const result = compute(data) return { type: `COMPUTE_ACTION`, payload: result } } 27
28.
Масштабирование 28 state <Component1 ... /> <Component2
... /> <Component3 ... /> <Component4 ... /> compute1 compute2 compute3 compute4
29.
Вычисления 29 const mapStateToProps =
state => ({ result: compute(state.data) })
30.
Мемоизация | Reselect import
{ createSelector } from 'reselect' const clustersSelector = createSelector( state => state.points, state => state.map.zoom, (points, zoom) => calculateClusters(points, zoom) ) 30
31.
Actions 31
32.
Flux Standard Action { type:
`DO_SOMETHING`, payload: { foo: `bar` }, meta: { foo: `bar` } } 32 { type: `DO_SOMETHING`, payload: new Error(), error: true }
33.
Realtime REALTIME gif Синхронизация экранов 33
34.
Plain object 34 store.dispatch(...) store.dispatch(...) store.dispatch(...) store.dispatch(...) SOCKETS if(action.meta &&
action.meta.sync) { sockets.emit(action) }
35.
thunk const asyncAction =
() => dispatch => { dispatch({ type: `REQUEST` }) fetch() .then(() => dispatch({type: `REQUEST_SUCCESS`})) .catch(() => dispatch({type: `REQUEST_ERROR`})) } 35
36.
thunk?? export const finallySend
= () => (dispatch, getState) => { const {phone, location, latlng, description, uploadId} = getState().toJS() dispatch({ type: SEND_REQUEST }) if (isEmpty(latlng)) { if (!location) { dispatch(sendResults({phone, location, description, uploadId})) return dispatch(setStep(`done`)) } geocodeLocation(location).then(payload => { const {lat: photoLat, lng: photoLon} = payload dispatch(sendResults({phone, location, description, uploadId, photoLat, photoLon})) }) } else { const {lat: photoLat, lng: photoLon} = latlng dispatch(sendResults({phone, location, description, uploadId, photoLat, photoLon})) } dispatch(setStep(`done`)) } 36 tests? scale?
37.
SAGA 37
38.
Sagas 38 ON_CLICK REQUEST REQUEST_SUCCESS function* rootSaga() { yield
takeLatest(`CLICK`, request) } function* request() { try { yield put({type: `REQUEST`}) const payload = yield call(api.requestData) yield put({type: `REQUEST_SUCCESS`, payload}) } catch(e) { yield put({type: `REQUEST_ERROR`}) } }
39.
Тесты const generator =
request() expect(generator.next().value).toEqual(put({type: `REQUEST`)) expect(generator.next().value).toEqual(call(api.requestData)) expect(generator.next(dummyResponse).value).toEqual(put({type: `REQUEST_SUCCESS`, payload})) 39
40.
Изоляция 40
41.
Проблема? 41 Component Component Component Component const componentReducer =
(state, action) => { ... case `CLICK`: return state.set(`clicked`, true) …. } cobmineReducers({ component1: componentReducer, component2: componentReducer ... }) `CLICK`
42.
Переиспользование компонент class ReusableComponent
extends Component { constructor() { this.state = {clicked: false} } handleOnClick() { this.setState({ clicked: true }) } render() { return <button onClick={this.handleOnClick} /> } } 42
43.
43
44.
redux-state connectState( mapLocalStateToProps, mapLocalDispatchToProps, mergeProps, componentReducer )(Component) 44 import {reducer as
states} from `redux-state` combineReducers({ states, ... })
45.
redux-multireducer 45 Component Component Component Component cobmineReducers({ component: multireducer({ `component1`: componentReducer, `component2`:
componentReducer, `component3`: componentReducer, ... }), ... }) `CLICK_reducerKey=component1` `CLICK_reducerKey=component2` `CLICK_reducerKey=component3` saga?
46.
ELM architecture 46
47.
47 ELM Model Update Command View Modularity REDUX State Reducer Saga Componet ???
48.
48 Updater Model Command View
49.
elm 49 Parent Child Child
50.
redux-elm //parentUpdater import { Updater
} from 'redux-elm'; import childUpdater, { init as childInit } from './childUpdater' export const init = () => Immutable({ child1: childInit(), child2: childInit() }); export default new Updater(init(), saga) .case(`Child1`, (model, action) => childUpdater(model.child1, action)) .case(`Child2`, (model, action) => childUpdater(model.child2, action)) .toReducer(); 50
51.
redux-elm //Parent import { forwardTo,
view } from 'redux-elm' import ChildView from 'redux-elm' export default view(({ model, dispatch }) => ( <div> <ChildView model={model} dispatch={forwardTo(dispatch, `Child1`)} /> <ChildView model={model} dispatch={forwardTo(dispatch, `Child2`)} /> </div> )); 51
52.
AMAZING REDUX seamless-immutable/immutable.js reselect redux-saga redux-elm 52
53.
Спасибо за внимание! 53
Jetzt herunterladen