SlideShare a Scribd company logo
1 of 57
Download to read offline
Let's kill
lifecycle
Александр Шушунов
version 1.3
2
Александр
Шушунов
или просто
Саша
3
из Твери
4
5
Как дошёл до жизни такой
Получаю деньги за код ≈ 14 лет
6
Как дошёл до жизни такой
7
8
Основная идея
f( )=
9
10
11
12
13
14
Lifecycle мешает команде React
reactjs.org/blog/2018/03/27/update-on-async-rendering.html
Observable
15
Что делать?
16
Что делать?
Не использовать
Lifecycle!
(хотя бы в клиентском коде)
17
Прежде чем продолжить...
18
19
redux-form
<Field name="boo" …>
20
redux-form
<Field name="boo" …>
Actions
Selectors
21
22
23
24
25
Пример.
Дальше все будет про DX
Значит пришло время IDE…
26
Проблема lifеcycle
Код превращается в кашу
Не декларативно!
27
А что нам нужно
• Как-то отреагировать на
изменения состояния
приложения
• Сделать сайд эффект
28
Complexity: Divide and Conquer!
How to decouple state and UI (a.k.a.
you don’t need componentWillMount)
29
Middleware
30
Middleware
«Выносите
сайд эффекты
в middleware»
© Древняя китайская мудрость
31
Как работает Redux-Saga
Action Reducer Store
32
Как работает Redux-Saga
Action Reducer Store
Middleware
33
34
35
Как работает Redux-Saga
36
Как работает Redux-Saga
Watcher
Worker
37
Как работает Redux-Saga
Последовательность
действий
Асинхронность
+
38
Как работает Redux-Saga
Последовательность
действий
Асинхронность
+ = Generators
39
Пример.
Опять пришло время IDE…
40
Все хорошо, но
• Надо работать только через
redux-store
• Generators
• Декларативно
• А что еще нужно )
41
42
Как работает redux-observable
43
Как работает redux-observable
Epic
actions
state
new actions
44
Пример.
И снова IDE…
45
Все хорошо, но
• Надо работать только через
redux-store
• Rx
• Еще декларативнее
• Нет специального DSL
46
47
А что если нельзя Middleware
48
Давайте напишем свое
+ =
react-redux-rxjs
github.com/redneckz/react-redux-rxjs
49
Давайте напишем свое
connect
props
state
new props
actions
50
Пример.
Это последний раз, обещаю
51
Все хорошо, но
• Две звезды на github L
• Rx
• Так же декларативно
• Не надо дополнительных
манипуляций с redux-store
52
53
Реальность
HOC
(lifecycle)
new propsprops
actions
54
Реальность
HOC
(lifecycle)
new propsprops
actions
55
Выводы
56
Выводы
f( )=
57
Вопросы?
github.com/AlexanderShushunov/lets-kill-lifecycle
@ashushunov
Alexander_Shushunov@epam.com

More Related Content

More from Maria Kuneva

Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...Maria Kuneva
 
Artem Zakharchenko - What I have to do at OdessaJS Conference
Artem Zakharchenko - What I have to do at OdessaJS ConferenceArtem Zakharchenko - What I have to do at OdessaJS Conference
Artem Zakharchenko - What I have to do at OdessaJS ConferenceMaria Kuneva
 
Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...
Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...
Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...Maria Kuneva
 
Artem Zakharchenko - What happens when you don't write the code. What advises...
Artem Zakharchenko - What happens when you don't write the code. What advises...Artem Zakharchenko - What happens when you don't write the code. What advises...
Artem Zakharchenko - What happens when you don't write the code. What advises...Maria Kuneva
 
Mihail Zachepilo - WebAssembly powered Machine Learning
Mihail Zachepilo - WebAssembly powered Machine LearningMihail Zachepilo - WebAssembly powered Machine Learning
Mihail Zachepilo - WebAssembly powered Machine LearningMaria Kuneva
 
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...Maria Kuneva
 

More from Maria Kuneva (6)

Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
 
Artem Zakharchenko - What I have to do at OdessaJS Conference
Artem Zakharchenko - What I have to do at OdessaJS ConferenceArtem Zakharchenko - What I have to do at OdessaJS Conference
Artem Zakharchenko - What I have to do at OdessaJS Conference
 
Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...
Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...
Denis Radin - Mining crypto in browser_ GPU, WebAssembly and all the good thi...
 
Artem Zakharchenko - What happens when you don't write the code. What advises...
Artem Zakharchenko - What happens when you don't write the code. What advises...Artem Zakharchenko - What happens when you don't write the code. What advises...
Artem Zakharchenko - What happens when you don't write the code. What advises...
 
Mihail Zachepilo - WebAssembly powered Machine Learning
Mihail Zachepilo - WebAssembly powered Machine LearningMihail Zachepilo - WebAssembly powered Machine Learning
Mihail Zachepilo - WebAssembly powered Machine Learning
 
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
Valentine Mezentsev, Gleb Dobzhanskyi, Vitalii Hurin - Bot Building: channels...
 

Alexander Shushunov - Let's kill lifecycle