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
Redux PINGPONG
Search
yutasuzuki
June 03, 2017
Programming
0
130
Redux PINGPONG
Nagoya.jsの飛び入りで発表させていただいた資料です。
自分の所感です。
yutasuzuki
June 03, 2017
Tweet
Share
More Decks by yutasuzuki
See All by yutasuzuki
ECMAScript Promise
yutasuzuki
1
320
Other Decks in Programming
See All in Programming
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
Kiroで始めるAI-DLC
kaonash
2
580
プロパティベーステストによるUIテスト: LLMによるプロパティ定義生成でエッジケースを捉える
tetta_pdnt
0
280
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
270
ユーザーも開発者も悩ませない TV アプリ開発 ~Compose の内部実装から学ぶフォーカス制御~
taked137
0
130
Swift Updates - Learn Languages 2025
koher
2
460
Compose Multiplatform × AI で作る、次世代アプリ開発支援ツールの設計と実装
thagikura
0
100
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
270
ぬるぬる動かせ! Riveでアニメーション実装🐾
kno3a87
1
200
詳解!defer panic recover のしくみ / Understanding defer, panic, and recover
convto
0
230
Rancher と Terraform
fufuhu
2
240
機能追加とリーダー業務の類似性
rinchoku
2
1.2k
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
The World Runs on Bad Software
bkeepers
PRO
70
11k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Testing 201, or: Great Expectations
jmmastey
45
7.6k
Designing for humans not robots
tammielis
253
25k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
7
840
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
A Tale of Four Properties
chriscoyier
160
23k
Building Adaptive Systems
keathley
43
2.7k
Context Engineering - Making Every Token Count
addyosmani
1
23
Music & Morning Musume
bryan
46
6.8k
Transcript
3FEVY1*/(10/(
None
ࢼͨ͠ϥΠϒϥϦ w SFEVYUIVOL w SFEVYTBHB w SFEVYPCTFSWBCMF
5SFOET
ࠓճ࡞ͬͨͷ ΫϦοΫ͢Δͱ1*/(Λมߋɻ̎ඵޙʹ10/(Λݩʹ͢ɻ
جຊతͳDPEF import { createAction } from 'redux-actions'; export const PONG
= 'PONG'; export const pong = createAction(PONG); export const PING = 'PING'; export const ping = createAction(PING); import { combineReducers } from 'redux' import { PONG, PING } from '../actions/' const reducer = (state = false, action) => { switch (action.type) { case PONG: return state = false break; case PING: return state = true default: return state } }; const reducers = combineReducers({ isPingPong: reducer }); export default reducers BDUJPOKT SFEVDFSKT
SFEVYUIVOL
SFEVYUIVOLͱ w 3FEVYᴈ໌ظ͔Β͍ΔϥΠϒϥϦɻ w ࡞ऀಉ͡ͳͷͰɺ΄΅ެࣜɻ w "DUJPOʹඇಉظͷϩδοΫΛԡ͠ࠐΜͰ͍͘ελΠϧɻ
SFEVYUIVOL import { createAction } from 'redux-actions' export const SYNC_EVENT
= 'SYNC_EVENT' export const syncEvent = createAction(SYNC_EVENT) export const ASYNC_EVENT = 'ASYNC_EVENT' export const asyncEvent = createAction(ASYNC_EVENT) export function asyncPingPong() { return (dispatch) => { dispatch(ping()) setTimeout(() => { dispatch(pong()) }, 2000) } } const mapDispatchToProps = (dispatch) => { return { onClickHandler: () => { dispatch(asyncPingPong()) } } } BDUJPOKT DPOUBJOFSKT
SFEVYUIVOLͷײ w "DUJPO$SFBUPS"DUJPOΦϒδΣΫτΛੜ͢Δ͚ͩʹ͍ͨ͠ɻ w ϥΠϒϥϦ͕ܰྔͳͷͰɺཧղ͍͢͠ɻ ࣮࣭ߦ͔͠ͳ͍ w ࠷ϝδϟʔͳ3FEVYͷඇಉظϥΠϒϥϦͳͷͰɺࣄྫ͕ଟ͍ɻ w
ࠓճͬͨඇಉظϥΠϒϥϦͰɺҰ൪ϋʔυϧ͕͍ɻ w ෳࡶͳϩδοΫΛ͜͜ʹԡ͠ࠐΉͷɺݸਓతʹඍົɻ
SFEVYTBHB
SFEVYTBHBͱ w δΣωϨʔλؔΛ༻͠ɺඇಉظͷॲཧΛಉظతʹॻ͚ΔΑ͏ʹͳΔɻ w SFEVYͷॲཧ͔ΒNJEEMFXBSFΛ༻͍ͯɺผεϨουʹΓग़͢Πϝʔδɻ action reducer saga
SFEVYTBHB import { delay } from 'redux-saga' import { put,
takeEvery } from 'redux-saga/effects' import { ping, PONG } from '../actions' function* pingPongSaga() { yield delay(2000) yield put(ping()) } export function* rootSaga() { yield takeEvery(PONG, pingPongSaga) } TBHBKT
SFEVYTBHBͷײ w ීஈશ͍ͬͯ͘ͳ͍δΣωϨʔλؔΛ৮Δ͖͔͚ͬʹͳͬͨɻ w SFEVYUIVOLͷ"DUJPOԚછ͔Βղ์ɻ w νʔϜ։ൃʹಋೖ͢ΔͱͳΔͱɺશମతʹֶशίετߴΊͩͱࢥ͏ɻ
SFEVYPCTFSWBCMF
SFEVYPCTFSWBCMFͱ w 3FBDUJWF9 3FBDUJWF&YUFOTJPO Λ༻੍͍ͨޚ͕Ͱ͖Δɻ w NJEEMFXBSFͰ"DUJPOΛड͚औͬͯɺ"DUJPOΛฦ͢ॲཧΛ&QJDͱݺͿɻ w SYKTʹґଘ͍ͯ͠Δɻ w
ެࣜϖʔδΛݟΔͱ/FUqJYͷϓϩμΫτʹݟ͑Δɻ
SFEVYPCTFSWBCMF import { createEpicMiddleware } from ‘redux-observable' import 'rxjs/add/operator/delay' import
'rxjs/add/operator/mapTo' import { PING, pong } from '../actions' const epic = (action$) => { return action$.ofType(PING) .delay(2000) .mapTo(pong()) } const epicMiddleware = createEpicMiddleware( epic ) export default epicMiddleware FQJDKT
SFEVYPCTFSWBCMFͷײ w ࠷ۙͷ3YʓʓͳྲྀΕ͔Β͢ΔͱɺΔՁ͋Γͦ͏ɻ w ॲཧͷϑϩʔ͕ݟ͍͢ɻ w খ͍͞ϓϩμΫτʹSYKTΛೖΕΔͷԿͱͳ͘ؾ͕Ҿ͚Δɻ
·ͱΊ
·ͱΊʢݸਓͷओ؍ʣ w ݸਓతͳΈ SFEVYUIVOLSFEVYPCTFSWBCMFSFEVYTBHB w ϓϩμΫτͷαΠζ͕খ͚͞ΕUIVOL͏ͱࢥ͏ɻ w ·ͨผͷΞϓϩʔν͕ग़͖ͯͨΒࢼͯ͠Έ͍ͨɻ
͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ