react, reactrouter, redux, redux-observable · renderdays() { let days =...
TRANSCRIPT
![Page 1: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/1.jpg)
React, ReactRouter, Redux, redux-observable
Алексей ОхрименкоIPONWEB, Москва
![Page 2: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/2.jpg)
Алексей Охрименко
?
![Page 3: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/3.jpg)
IPONWEB
![Page 4: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/4.jpg)
14
![Page 5: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/5.jpg)
![Page 6: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/6.jpg)
React компоненты
![Page 7: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/7.jpg)
create-react-app calendar
![Page 8: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/8.jpg)
render() { return [ <div className="month"> <ul> <li className="prev">❮</li> <li className="next">❯</li> <li><div>August</div><span>2017</span></li> </ul> </div>, <ul className="weekdays"> <li>Mo</li> </ul>, <ul className="days"> <li>1</li> </ul> ]; }
![Page 9: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/9.jpg)
render() { return [ <div className="month"> <ul> <li className="prev">❮</li> <li className="next">❯</li> <li><div>August</div><span>2017</span></li> </ul> </div>, <ul className="weekdays"> <li>Mo</li> </ul>, <ul className="days"> <li>1</li> </ul> ]; }
![Page 10: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/10.jpg)
render() { return [ <div className="month"> <ul> <li className="prev">❮</li> <li className="next">❯</li> <li><div>August</div><span>2017</span></li> </ul> </div>, <ul className="weekdays"> <li>Mo</li> </ul>, <ul className="days"> <li>1</li> </ul> ]; }
![Page 11: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/11.jpg)
render() { return [ <div className="month"> <ul> <li className="prev">❮</li> <li className="next">❯</li> <li><div>August</div><span>2017</span></li> </ul> </div>, <ul className="weekdays"> <li>Mo</li> </ul>, <ul className="days"> <li>1</li> </ul> ]; }
![Page 12: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/12.jpg)
render() { return [ <div className="month"> <ul> <li className="prev">❮</li> <li className="next">❯</li> <li><div>August</div><span>2017</span></li> </ul> </div>, <ul className="weekdays"> <li>Mo</li> </ul>, <ul className="days"> <li>1</li> </ul> ]; }
![Page 13: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/13.jpg)
![Page 14: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/14.jpg)
![Page 15: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/15.jpg)
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), month: now.getMonth() + 1 } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
![Page 16: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/16.jpg)
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), month: now.getMonth() + 1 } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
![Page 17: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/17.jpg)
next() { this.setState(getNextYearMonth(this.state.year, this.state.month)); } prev() { this.setState(getPrevYearMonth(this.state.year, this.state.month)); }
![Page 18: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/18.jpg)
render() { return [ <div className="month"> <ul> <li className="prev">❮</li> <li className="next">❯</li> <li><div>August</div><span>2017</span></li> </ul> </div>, <ul className="weekdays"> <li>Mo</li> </ul>, <ul className="days"> <li>1</li> </ul> ]; }
![Page 19: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/19.jpg)
<div className="month" key="month"> <ul> <li onClick={this.prev} className="prev">❮</li> <li onClick={this.next} className="next">❯</li> <li> <div>{getFullMonthName(this.state.month)}</div> <div>{this.state.year}</div> </li> </ul> </div>,
![Page 20: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/20.jpg)
<div className="month" key="month"> <ul> <li onClick={this.prev} className="prev">❮</li> <li onClick={this.next} className="next">❯</li> <li> <div>{getFullMonthName(this.state.month)}</div> <div>{this.state.year}</div> </li> </ul> </div>,
![Page 21: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/21.jpg)
<ul className="weekdays" key="weekdays"> <li>Mo</li> <li>Tu</li> <li>We</li> <li>Th</li> <li>Fr</li> <li>Sa</li> <li>Su</li> </ul>,
![Page 22: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/22.jpg)
this.renderDays()
![Page 23: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/23.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 24: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/24.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 25: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/25.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 26: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/26.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 27: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/27.jpg)
let items = new Array(days).map(() => 1)
![Page 28: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/28.jpg)
let items = new Array(days).fill().map(() => 1)
![Page 29: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/29.jpg)
null, undefined
![Page 30: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/30.jpg)
null, undefined, undefined value
![Page 32: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/32.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 33: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/33.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 34: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/34.jpg)
renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month); let items = new Array(days).fill().map((_, index) => { let cls = index === 0 ? 'skip' + skip : ''; return <li className={cls} key={index}>{index + 1}</li> }); return ( <ul className="days" key="days"> {items} </ul> ) }
![Page 35: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/35.jpg)
![Page 36: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/36.jpg)
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), weekNumber: getWeekNumber(now) } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
![Page 37: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/37.jpg)
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), weekNumber: getWeekNumber(now) } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), month: now.getMonth() + 1 } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
![Page 38: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/38.jpg)
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), weekNumber: getWeekNumber(now) } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), month: now.getMonth() + 1 } this.next = this.next.bind(this); this.prev = this.prev.bind(this); }
![Page 39: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/39.jpg)
CalendarContainer.js
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), month: now.getMonth() + 1, weekNumber: getWeekNumber(now) } }
![Page 40: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/40.jpg)
Container / Page / Atomic Design
constructor() { super(); let now = new Date(); this.state = { year: now.getFullYear(), month: now.getMonth() + 1, weekNumber: getWeekNumber(now) } }
![Page 41: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/41.jpg)
CalendarContainer.js
return [ <Month year={this.state.year} month={this.state.month}></Month>, <Week year={this.state.year} month={this.state.weekNumber}></Week> ];
![Page 42: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/42.jpg)
Умные/Глупые компоненты
![Page 43: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/43.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Components Props
![Page 44: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/44.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Components Props
![Page 45: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/45.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Components Props
![Page 46: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/46.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Components Props
![Page 47: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/47.jpg)
![Page 48: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/48.jpg)
![Page 49: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/49.jpg)
![Page 50: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/50.jpg)
React Router - на рану
![Page 51: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/51.jpg)
import { BrowserRouter } from 'react-router-dom'
ReactDOM.render(( <BrowserRouter> <App /> </BrowserRouter> ), document.getElementById('root'))
![Page 52: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/52.jpg)
<Switch> <Route exact path='/' component={Month}/> <Route path='/week' component={Week}/> </Switch>
![Page 53: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/53.jpg)
![Page 54: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/54.jpg)
![Page 55: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/55.jpg)
Кто не использует Router?
![Page 56: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/56.jpg)
![Page 57: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/57.jpg)
… у вас возможно уважительные причины
![Page 58: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/58.jpg)
![Page 59: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/59.jpg)
«About Page»
![Page 60: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/60.jpg)
Состояние приложения
![Page 61: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/61.jpg)
Состояние приложения != Состояние компонента
![Page 62: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/62.jpg)
Состояние приложения != this.setState
![Page 63: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/63.jpg)
![Page 64: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/64.jpg)
Cостояние
![Page 65: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/65.jpg)
![Page 66: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/66.jpg)
Состояние приложения - это одно из главных отличий Frontend от Backend
![Page 67: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/67.jpg)
https://www.youtube.com/watch?v=udNHwANuicU
State Managers
![Page 68: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/68.jpg)
Redux
![Page 69: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/69.jpg)
Dan Abramov
Данила Абрамов
![Page 70: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/70.jpg)
![Page 71: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/71.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
![Page 72: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/72.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Store
ReduxDispatch
![Page 73: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/73.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Store
ReduxDispatch
Subscribe
![Page 74: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/74.jpg)
Коммуникация между компонентами
React
ROOT
TARGET
Store
ReduxDispatch
Subscribe
![Page 75: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/75.jpg)
Умные/Глупые компоненты все-равно нужно использовать
![Page 76: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/76.jpg)
Увы в коде ничего проще не становиться
![Page 77: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/77.jpg)
Reducers, Action, Store, ActionCreators синхронны :(
![Page 78: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/78.jpg)
SideEffect Managers
![Page 79: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/79.jpg)
SideEffect Managers
●thunk ●redux-saga ●redux-loop ●redux-observable
![Page 80: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/80.jpg)
SideEffect Managers
●thunk ●redux-saga ●redux-loop ●redux-observable
![Page 81: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/81.jpg)
Promise
![Page 82: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/82.jpg)
function a() { return 1; }
function b() { return a() + 2; }
console.log(b());
![Page 83: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/83.jpg)
function a() { return 1; }
function b() { return a() + 2; }
console.log(b());
![Page 84: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/84.jpg)
function a() { return 1; }
function b() { return a() + 2; }
console.log(b());
![Page 85: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/85.jpg)
function a() { return new Promise((resolve, reject) => { resolve(1); }); }
function b() { return a().then((v) => v + 2); }
b().then(console.log)
![Page 86: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/86.jpg)
function a() { return new Promise((resolve, reject) => { resolve(1); }); }
function b() { return a().then((v) => v + 2); }
b().then(console.log)
![Page 87: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/87.jpg)
function a() { return new Promise((resolve, reject) => { resolve(1); }); }
function b() { return a().then((v) => v + 2); }
b().then(console.log)
![Page 88: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/88.jpg)
Проблемы Promise
●Одно значение
![Page 89: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/89.jpg)
Проблемы Promise
●Одно значение ●Отмена
![Page 90: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/90.jpg)
Проблемы Promise
●Одно значение ●Отмена ●Повтор
![Page 91: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/91.jpg)
Проблемы Promise
●Одно значение ●Отмена ●Повтор ●Отсутствие синхронности
![Page 92: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/92.jpg)
Проблемы Promise
●Одно значение ●Отмена ●Повтор ●Отсутствие синхронности ●Finally *
![Page 93: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/93.jpg)
Observable
![Page 94: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/94.jpg)
function a() { return [1]; }
function b() { return a().map((v) => v + 2); }
console.log(b());
![Page 95: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/95.jpg)
function a() { return [1]; }
function b() { return a().map((v) => v + 2); }
console.log(b());
![Page 96: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/96.jpg)
function a() { return [1]; }
function b() { return a().map((v) => v + 2); }
console.log(b());
![Page 97: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/97.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
![Page 98: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/98.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
![Page 99: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/99.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
map, filter, scan
![Page 100: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/100.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
delay, debounce, throttle
![Page 101: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/101.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
![Page 102: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/102.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
![Page 103: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/103.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); done(); }); }
function b() { return a().map((v) => v + 2); }
b().subscribe(console.log);
Hot vs Cold
![Page 104: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/104.jpg)
Higher Order Observable
![Page 105: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/105.jpg)
Promise.all, Promise.race
![Page 106: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/106.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); next(2); done(); }); }
function b() { return a().switchMap((v) => ajax.get('/api')); }
b().subscribe(console.log);
![Page 107: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/107.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); next(2); done(); }); }
function b() { return a().switchMap((v) => ajax.get('/api')); }
b().subscribe(console.log);
![Page 108: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/108.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); next(2); done(); }); }
function b() { return a().switchMap((v) => ajax.get('/api')); }
b().subscribe(console.log);
![Page 109: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/109.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); next(2); done(); }); }
function b() { return a().switchMap((v) => ajax.get('/api')); }
b().subscribe(console.log);
![Page 110: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/110.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); next(2); done(); }); }
function b() { return a().switchMap((v) => ajax.get('/api')); }
b().subscribe(console.log);
![Page 111: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/111.jpg)
function a() { return Observable.create(function(next, error, done) { next(1); next(2); done(); }); }
function b() { return a().switchMap((v) => ajax.get('/api')); }
b().subscribe(console.log);
![Page 112: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/112.jpg)
RxJs - это lodash для Observableъ
> 130 методов
![Page 113: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/113.jpg)
redux-observable
![Page 114: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/114.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 115: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/115.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 116: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/116.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 117: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/117.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 118: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/118.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 119: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/119.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 120: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/120.jpg)
import { ajax } from 'rxjs/observable/dom/ajax';
const fetchEpic = action$ => action$.ofType(FETCH) .switchMap(action => ajax.getJSON(`/api/${action.payload}`) .map(response => fetchFulfilled(response)) .catch(error => Observable.of({ type: FETCH_REJECTED, payload: error.xhr.response, error: true })) );
![Page 121: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/121.jpg)
Очень умная очередь запросов
![Page 122: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/122.jpg)
.debounce(1000)
.distinctUntilChanged()
.switchMap(…)
Дожидаемся реальных изменений
![Page 123: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/123.jpg)
.retry(3)
500
![Page 124: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/124.jpg)
.retryWhen(function (errors) { return Observable .zip( Observable.range(1, MAX_RETRIES), errors, (i, e) => i ) .flatMap((i) => Observable.timer(i * 1000)); })
Exponential Backoff
![Page 125: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/125.jpg)
![Page 126: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/126.jpg)
Послесловие…
![Page 127: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/127.jpg)
1) React компоненты (create-react-app)
![Page 128: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/128.jpg)
1) React компоненты (create-react-app) 2) Умные/Глупые компоненты
![Page 129: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/129.jpg)
1) React компоненты (create-react-app) 2) Умные/Глупые компоненты 3) Router
![Page 130: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/130.jpg)
1) React компоненты (create-react-app) 2) Умные/Глупые компоненты 3) Router 4) State Manager ( Redux … )
![Page 131: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/131.jpg)
1) React компоненты (create-react-app) 2) Умные/Глупые компоненты 3) Router 4) State Manager ( Redux … ) 5) Redux -> SideEffect Manager -> ReduxObservable
![Page 132: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/132.jpg)
1) React компоненты (create-react-app) 2) Умные/Глупые компоненты 3) Router 4) State Manager ( Redux … ) 5) Redux -> SideEffect Manager -> ReduxObservable 6) Observable / 2 > Promise
![Page 133: React, ReactRouter, Redux, redux-observable · renderDays() { let days = getDaysInMonth(this.state.year, this.state.month); let skip = getFirstDayWeekday(this.state.year, this.state.month);](https://reader030.vdocuments.net/reader030/viewer/2022040102/5ec836bc6057c1295e33527a/html5/thumbnails/133.jpg)
Twitter: Ai_boy http://bit.ly/2G05fuo
Алексей Охрименко