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
Yet another side effect layer for Redux
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Daisuke Mino
April 24, 2018
Programming
2.8k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Yet another side effect layer for Redux
Daisuke Mino
April 24, 2018
More Decks by Daisuke Mino
See All by Daisuke Mino
複雑なコンポーネントで 状態をもつのをやめた話
minodisk
0
140
io.Writerで学ぶGoのインターフェース
minodisk
0
250
Goのエラーハンドリング
minodisk
0
210
Other Decks in Programming
See All in Programming
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
540
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.6k
依存関係から依存物へ―Dependencyという言葉の歴史をひも解く
j_lee
0
120
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
750
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
340
New "Type" system on PicoRuby
pocke
1
870
TAKTでAI駆動開発の品質を設計する
j5ik2o
6
1.2k
net-httpのHTTP/2対応について
naruse
0
480
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
140
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
400
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
330
Featured
See All Featured
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
250
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
How to build a perfect <img>
jonoalderson
1
5.6k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
230
Ethics towards AI in product and experience design
skipperchong
2
310
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
240
Bash Introduction
62gerente
615
220k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
220
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
430
Transcript
Yet another side effect layer for Redux Scramble! #1 @minodisk
Redux͕Δ͜ͱ άϩʔόϧεςʔτΛҡ࣋͢ΔͨΊͷ࣮ • Connector • Dispatcher • Reducer • Store
Redux͕Βͳ͍͜ͱ ෭࡞༻ͷ͋ΔॲཧΛॻ͘ॴͷఏڙ • APIτϥοΩϯά༻ϝιουͷίʔϧ • Local StorageCookieͷΞΫηε • ReactΞϓϦέʔγϣϯ֎ͷDOMૢ࡞
Ͳ͜ͰΔ͔ʁ େ͖͚͘Δͱ͜Μͳൊ͕͋Γͦ͏ • ComponentͰΔ • ActionൃߦલʹΔ redux-thunk • ActionൃߦޙɺReduceલʹΔ redux-saga
Ͳ͜ͰΔ͔ʁ • ComponentͰΔͷ֎ • redux-thunkActionΛDispatch͢Δͷ͔ Action DispatcherΛDispatch͢Δͷ͔౷Ұײ͕ ͳ͍ίʔυʹͳͬͯ͠·͏ • redux-sagaผϨΠϠʔͰΔͷͰɺ
֤ϨΠϠʔ͕ͦΕͧΕͷʹूதͰ͖Δ
redux-sagaͷΑ͞ • ֤ϨΠϠʔ͕ࣗͷʹूதͰ͖Δ • ViewActionΛൃߦ͢Δ͚ͩ • ෭࡞༻ϨΠϠʔͰActionΛड͚औΓɺ ActionΛൃߦ͢Δ͚ͩ • ActionͷTypeΛϑοΫͯ͠ॲཧΛࣗ༝ʹॻ͚Δ
redux-sagaͷͭΒΈ • Generatorਏ͍ • ςετਏ͍ • Effectsؔਏ͍
ສೳނͷਏΈ • GeneratorͳΒશͯͷ͜ͱ͕Ͱ͖Δ͔͠Εͳ ͍ • ݱ࣮ʹҰൠతͳWebΞϓϦέʔγϣϯͰॻ͘ ॲཧͷ99%Async/Await/Promise.allͰͬ ͍͚ͯΔ୯७ͳίʔυ • 1%ΛຒΊΔͨΊʹෳࡶੑ͕ۃ·ͬͯΔ
Զୡ͕ཉ͔ͬͨ͠ͷ
Image by www.projectcartoon.com / CC BY 3.0
࡞ͬͨ
redux-spork
Spork is Կ?
Spoon x Fork Image by Wtshymanski at English Wikipedia /
CC BY-SA 3.0
Specifications • action.typeΛΩʔʹcallbackΛొ͢Δ • callbackͨͩͷfunctionͰɺasyncʹͰ͖Δ • callbackʹ͞ΕΔdispatchϝιουͰผactionΛൃߦ • ൃߦ͞Εͨaction࠶ϑοΫ͞Εcallback͕ݺΕΔ •
1-action:N-callback, N-action:1-callback
Fork
Component Reducer Action
Component Reducer Fork Action
Component Reducer Fork Action Action Dispatch
Component Reducer Fork Action Action Dispatch Action
Component Reducer Fork Action Action Dispatch Fork
Component Reducer Fork Action Action Dispatch
Component Reducer Fork Action Action Dispatch
Component Reducer ORDER USER_FETCH USER_FETCHED
Merge
Component Reducer ORDER Merge USER_FETCH USER_FETCHED
͜Μͳ͔Μ͡ 1 fork('ORDER', async (action, dispatch) => {¬ 2 dispatch({
type: 'USER_FETCH', action.payload.userID })¬ 3 const { payload } = await merge('USER_FETCHED')¬ 4 const resp = await fetch(`/api/orders`, {¬ 5 method: 'POST',¬ 6 body: JSON.stringify({ productID: action.payload.productID }),¬ 7 })¬ 8 dispatch({ type: 'ORDERED', payload: JSON.parse(resp.body) })¬ 9 })
ͱ͜ΖͰ
redux-observable ʹࢥ͕ࣅͯΔΑͶʁ
Spork Image by Wtshymanski at English Wikipedia / CC BY-SA
3.0
Observable Image by Dave Taylor at Flickr / CC BY
2.0
·ͱΊ • ϨΠϠʔ͕Γ͚ΒΕΔ • ͷ • γϯϓϧ • Async/AwaitͰ͍͖ͬͯ
Repository • https://github.com/folio-sec/redux-spork • https://www.npmjs.com/package/redux- spork
͝ਗ਼ௌ͍͖ͨͩ ͋Γ͕ͱ͏͍͟͝·ͨ͠