Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Why Redux?
Search
Takanori Maeda
September 30, 2016
Programming
170
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Why Redux?
社内LT大会用のスライドです。Reduxの紹介。
Takanori Maeda
September 30, 2016
Transcript
8 slides
Why Redux? @maechabin http://redux.js.org/
Reduxͱʁ • WebΞϓϦέʔγϣϯΛߏங͢ΔΞϓϩʔνͷͻͱͭʢঢ়ଶ Λཧ͢ΔͨΊͷϑϨʔϜϫʔΫʣ • ࡞ऀDan Abramovࢯ@Facebook • Facebookͷఏএ͢ΔFluxΞʔΩςΫνϟͷӨڹΛड͚͍ͯΔ •
࠷ॳFluxϑϨʔϜϫʔΫͷͻͱͭʹ͗͢ͳ͔͕ͬͨɺݱࡏ Ұਓউͪঢ়ଶ • ΫϩεϓϥοτϑΥʔϜʹରԠʢΫϥΠΞϯτ / αʔόʔ / ωΠςΟϒͰಈ͘ʣ • Reactͷঢ়ଶΛཧ͢ΔͨΊʹηοτͰΘΕΔ͜ͱ͕ଟ͍ • GitHubͷελʔ23,663ʢ20169݄30ݱࡏʣ
ReduxͷΈ • σʔλҰํʹ͔͠ྲྀΕͳ͍ • ActionɺReducerɺStoreͷ3ͭͷ෦͔ Βߏ͞ΕΔ • Store1ͭͷΞϓϦέʔγϣϯʹඞͣ1 ͭ •
StoreΞϓϦέʔγϣϯશମͷঢ়ଶ ʢStateʣΛObjectπϦʔͱͯ͠อ࣋ • ঢ়ଶʢStateʣImmutable • ঢ়ଶΛʢStateʣΛߋ৽͢Δ།Ұͷํ๏ ɺActionΛൃՐͤ͞Δ͜ͱ • ActionΞΫγϣϯ໊ͱঢ়ଶͷΛ࣋ ͬͨ୯ͳΔΦϒδΣΫτ • Reducer෭࡞༻ͷͳ͍७ਮͳؔɻ ݱࡏͷঢ়ଶͱActionΛҾʹͱΔ
Viewͷ࣮ • جຊతʹPubSubύλʔϯ • StoreͰ༻ҙ͞Ε͍ͯΔAPIΛ͏ ঢ়ଶʢstateʣͷΞΫηε ɹɹɹ=> getState()ϝιου ঢ়ଶʢstateʣͷߋ৽ ɹɹɹ=>
dispatch(action)ϝιου ϦεφʔΛొ ɹɹɹ=> subscribe(listener)ϝιου Ϧεφʔͷొղআ => subscribe(lstener)ϝιου ɹɹɹɹʹΑͬͯฦ͞Εͨؔ // ActionをReducerに伝播 store.dispatch(actionCreators()); // stateの状態を購読。状態に変化が // あったらリスナーを実行 store.subscribe(() => { /* リスナーの処理を書く */ // stateを取得 store.getState(); }); Viewͷ࣮ྫ
ReactͰReduxΛ͏ • ReactViewʹಛԽͨ͠ϥΠϒϥϦͰ͋ΓɺΞϓ Ϧέʔγϣϯͷن͕େ͖͘ͳΔͱঢ়ଶͷཧ ͕ෳࡶʹͳΓɺઃܭ͕͘͠ͳΔ͔Β • ReactͷίϯϙʔωϯτؒͷόέπϦϨʔΛճආ ͍͔ͨ͠Β • ༩͑ΒΕͨʹج͍ͮͯίϯϙʔωϯτ͕Ϩϯμ
Ϧϯά͞ΕΔΑ͏ʹͳΔͨΊReactͷςετ͕؆ ୯ʹͳΔ͔Β ReactͰReduxΛ͏ཧ༝
ReactͰReduxΛ͏ʹʁ React-ReduxʢnpmʣΛͬͯReactͱ࿈ܞ https://github.com/reactjs/react-redux ͍ํͳͲͷৄࡉࢲͷϒϩάهࣄΛࢀরʂ ↓ Reduxͷ࣮ͱReactͱͷ࿈ܞΛγϯϓϧͳαϯ ϓϧΛͬͯղઆ http://mae.chab.in/archives/2885
·ͱΊ • ΞϓϦέʔγϣϯͷঢ়ଶΛͻͱͭͷॴͰอ ࣋͢ΔͨΊɺঢ়ଶͷཧָ͕ʹͳΔ • ΞϓϦέʔγϣϯ͕ෳࡶʹͳ͖ͬͯͨͱ͖ͷ εέʔϧՄೳ • ReactͰͷ։ൃ͕ΑΓָ͘͠ͳΔ •
ͨͩ͠Viewͷ࣮ReactͰͳͯ͘ྑ͍ • ྲྀߦ͖͍ͬͯͯΔͷͰ͓͍֮͑ͯͯଛͳ͠
https://github.com/reactjs/redux ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ
More Decks by Takanori Maeda
See All by Takanori Maeda
モバイルWeb開発最前線 -PWA開発パターン「PRPL」の紹介-
maechabin
0
600
Why React and not jQuery?
maechabin
0
240
最新フロントエンド事情2016年版
maechabin
1
820
Other Decks in Programming
See All in Programming
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
The Cost of the DOM
ypresto
2
720
Apache Airflow Introduction
leew
1
100
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
340
[DroidKnights 2026] Workflow AX: From Auto-Documented Policies to E2E Testing
raeminkang
0
610
眠らない開発チームの作り方
biwakonbu
0
160
小さなアプリを作って公開するまで
onozaty
0
260
RaspberryPi 5で軽くはじめるk3sとtailscaleを用いたホームサーバー構築 (1)
nasum
0
450
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
130
Jujutsu で毎日のバージョン管理に「安心」と「直感性」を
oukayuka
0
110
Crash Auto Pipelines
veronikapj
1
450
Kiro Crewによる開発体験ーKiro CrewでStrands Decider 2B に関する技術検証をやってみた
satoshi256kbyte
1
210
Featured
See All Featured
sira's awesome portfolio website redesign presentation
elsirapls
0
530
Music & Morning Musume
bryan
48
7.5k
Code Reviewing Like a Champion
maltzj
529
40k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
610
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
530
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
680
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
680
Unsuck your backbone
ammeep
672
58k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
3k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
590
The Limits of Empathy - UXLibs8
cassininazir
2
800