Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Pitch - Lidando com Efeitos Colaterais com Redu...
Search
Filipe Costa
February 11, 2017
Programming
0
370
Pitch - Lidando com Efeitos Colaterais com Redux Saga
Pitch para palestrar no CEJS 2017.
Filipe Costa
February 11, 2017
Tweet
Share
More Decks by Filipe Costa
See All by Filipe Costa
Lidando com Efeitos Colaterais com Redux Saga
filipebarcos
0
210
Rust for Rubysts
filipebarcos
2
240
Limpando Seu Código JS Com O Padrão Pub/Sub
filipebarcos
0
190
Tu trabalha em casa?? Que moleza hein!
filipebarcos
0
120
Rediscovering OOP in Rails World
filipebarcos
0
89
jQuery Bad Practices
filipebarcos
2
250
Intro to Ruby
filipebarcos
1
120
Other Decks in Programming
See All in Programming
Improving my own Ruby thereafter
sisshiki1969
1
160
楽して成果を出すためのセルフリソース管理
clipnote
0
190
Navigating Dependency Injection with Metro
zacsweers
3
3.5k
AIでLINEスタンプを作ってみた
eycjur
1
230
時間軸から考えるTerraformを使う理由と留意点
fufuhu
16
4.8k
print("Hello, World")
eddie
2
530
The Past, Present, and Future of Enterprise Java with ASF in the Middle
ivargrimstad
0
170
奥深くて厄介な「改行」と仲良くなる20分
oguemon
1
560
Swift Updates - Learn Languages 2025
koher
2
510
実用的なGOCACHEPROG実装をするために / golang.tokyo #40
mazrean
1
290
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
550
FindyにおけるTakumi活用と脆弱性管理のこれから
rvirus0817
0
540
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
77
6k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
4 Signs Your Business is Dying
shpigford
184
22k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
How to train your dragon (web standard)
notwaldorf
96
6.2k
Fireside Chat
paigeccino
39
3.6k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.7k
Transcript
Lidando com Efeitos Colaterais com Redux Saga @filipebarcos
Redux
"Evolui ideias do Flux, mas evita suas complexidades pegando dicas
do Elm" — github.com/reactjs/redux Redux
Redux UI Reducer Store Action dispatched (currentState, action) => newState
New State
Redux UI Middleware Reducer Store Action dispatched (currentState, action) =>
newState New State Action forwarded Action dispatched
Redux Saga
github.com/redux-saga/redux-saga
JavaScript Generator Functions*
ES6
Podemos paralisar a execução da função
function* foo(x) { const y = 2 * (yield (x
+ 1)); const z = yield (y / 3); return (x + y + z); } var it = foo(5); // note: not sending anything into `next()` here console.log(it.next()); // { value:6, done:false } console.log(it.next(12)); // { value:8, done:false } console.log(it.next(13)); // { value:42, done:true } https://davidwalsh.name/es6-generators
import { call, put } from 'redux-saga/effects'; export function* fetchData(action)
{ try { const data = yield call(Api.fetchUser, action.payload.url); yield put({type: "FETCH_SUCCEEDED", data}); } catch (error) { yield put({type: "FETCH_FAILED", error}); } } function* watchFetchData() { yield takeEvery('FETCH_REQUESTED', fetchData); } https://redux-saga.github.io/redux-saga/docs/basics/UsingSagaHelpers.html
import { takeEvery } from 'redux-saga'; // FETCH_USERS function* fetchUsers(action)
{ ... } // CREATE_USER function* createUser(action) { ... } // use them in parallel export default function* rootSaga() { yield takeEvery('FETCH_USERS', fetchUsers); yield takeEvery('CREATE_USER', createUser); } https://redux-saga.github.io/redux-saga/docs/basics/UsingSagaHelpers.html
github.com/filipebarcos/redux-saga-example
gist.github.com/filipebarcos/ 0a137d6ca837c117f999958a365fc5b6
Obrigado. @filipebarcos