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
何でもかんでもStoreにぶち込まないで実装をする話 with Vuex
Search
slont
May 20, 2020
Programming
1.5k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
何でもかんでもStoreにぶち込まないで実装をする話 with Vuex
slont
May 20, 2020
More Decks by slont
See All by slont
SaaS型保険クラウド「Inspire」関連サービス全てをVue.jsで作ってる話
slont
1
1.1k
ぼくのかんがえたさいきょうのVueあーきてくちゃ
slont
9
4.1k
Other Decks in Programming
See All in Programming
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
🇪🇸 React Alicante 2026 (Workshop)
ythecombinator
PRO
0
100
dotNET_vulnclicker_intro.pdf
deka_morita
0
150
設計次第でAIコードの読む量は減らせる / designing-for-code-reading
minodriven
35
17k
golang-bob.pdf
iwatsukayura
0
130
Domain-Driven Transformation
hschwentner
2
2.3k
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
890
Groovy as a human and AI friendly programming language
paulk
0
100
残高管理から台帳サービスへの進化
artoy
1
210
R8 の設定見直しでアプリサイズ削減
andpad
0
220
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
180
Featured
See All Featured
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Unsuck your backbone
ammeep
672
58k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
The agentic SEO stack - context over prompts
schlessera
0
970
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
500
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
500
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Claude Code のすすめ
schroneko
67
230k
The Curious Case for Waylosing
cassininazir
1
570
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
220
Building Flexible Design Systems
yeseniaperezcruz
330
41k
Transcript
ԿͰ͔ΜͰStoreʹͿͪࠐ· ͳ͍Ͱ࣮Λ͢Δ with Vuex 2020.05.20@PWA Night vol.16
About me • Twitter - @_slont • גࣜձࣾFinatext - Engineer
• Vue.js, Java, Go, Elixir • ࣗ࡞PWA Paroty
https://medium.com/finatext/composition-api-for-vue3-63631dbadcef https://medium.com/finatext/vue-on-ionic%E3%81%A7web
ίτͷൃ
None
શͯStoreͰཧ…ʁ ͍͔ͭഁ͢Δ͜ͱʹݟ͑Δʂʢʁʣ
VuexΛ༻͍ͨ StoreύλʔϯͰͷ࣮Λߟ͑Δ
Vuexͱ • ঢ়ଶཧύλʔϯ + ϥΠϒϥϦ → Flux, ReduxͷྲྀΕΛΉ → αʔυύʔςΟͰӬଓԽՄೳ
• Vueίϯϙʔωϯτ͔Β$storeܦ༝ͰΞΫηεՄೳ → ͜Εάϩʔόϧมͱͯ͠ͷੑ࣭Λ࣋ͭͷͰɺศٓతʹͦ͏ݺͿ ɹ→ ʮάϩʔόϧม͡Όͳ͍ͩΖ͏͕ʂʯͱ͔ݴΘΕ·͕ͨ͠ɺఆٛͰͳ͘ৼΔ͍ͷͳͷͰແࢹ
άϩʔόϧม͕ ԿނΞϯνύλʔͳͷ͔
None
StoreͰͬͪΌ͏ਓͷࢥߟʢໝʣ • ʮάϩʔόϧͬͯதͰείʔϓΛͬͯΔ͔Βେৎʯ → ͋ΔίϯϙʔωϯτείʔϓͰด͡Δ͜ͱ͕Ͱ͖ΔมΛάϩʔόϧʹग़ͯ͠Δ࣌Ͱʢґଘ͕ؔʣີͰ͢ → είʔϓͷωʔϜεϖʔε͕িಥͨ͠ΒऴΘΔ • ʮ݁ہAPIͱ͔άϩʔόϧͳͷͰ·ͱΊͨํ͕ྑ͍ʯ →
ेݸҎ্ͷAPIΛ͏େنͳΞϓϦͩͱstore͕େʹͳͬͯഁ͢Δ → ࢲݟ͕ͩɺstoreͱ͍͏໊લΛ༻ͯ͠͠·ͬͨͷ͕ྑ͘ͳ͔ͬͨ • ʮείʔϓҙࣝ͠ͳͯ͘ྑ͍ͷͰศརʯ → ؒҧ͍ͳ͍ → େنΞϓϦ͡Όͳ͍͔Βʮͨ·ͨ·ʯϝϦοτ͚ͩڗडͰ͖͍ͯΔ͚ͩ • ʮPropsͷόέπϦϨʔ͕ݏͩʯ → Θ͔ΓΈ͕ਂ͍ → ߏԽɾઃܭ্͕ख͘Ͱ͖͍ͯͳ͍Մೳੑ
StoreͰશͯཧύλʔϯ ʢͦΜͳ͜ͱͨ͠ܦݧ͕ͳ͍ͷͰໝʣ
/components/SpecialButton.vue <template> button.button(:disabled=“disabled”) ΞΫγϣϯ <script> computed: { disabled() { return
this.$store.getters[‘page/isDisabled’] } } /store/modules/page.ts state = { canOperate: false, // ૢ࡞ݖݶ hasContent: false // ίϯςϯπ͕͋Δ͔ } getters = { isDisabled(s) { // Ϙλϯ͕ඇ׆ੑ͔ return !(s.canOperate && s.hasContent) } } views ┗ Page.vue // ϖʔδίϯϙʔωϯτ components ┣ Content.vue // Page.vue͔ΒݺΕΔ ┗ SpecialButton.vue // Content.vue͔ΒݺΕΔ store ┣ modules ┣ ┗ page.ts // Page.vueʹؔ͢Δstore ┗ index.ts • disabeldpropsͰ͖͢ → SpecialButton͕storeͷมߋʹґଘ͍ͯ͠Δ • page.tsͷstateʹ֨ೲ͞ΕΔཻ͕ό ϥόϥ → ΄΅࣮֬ʹωʔϜεϖʔεͷίϯϑϦΫτ͕ى͜Δ • ଞʹ৭ʑ͋Δׂ͕Ѫ
Vuex (Store) ΛͲ͏͏ͷ͔
άϩʔόϧมͰ͋Δ͖ͷ & ӬଓԽ • ʮϩάΠϯϢʔβใʯʮઃఆใʯͳͲͷɺجຊతʹߋ৽͕গͳ ͘ɺͲͷίϯϙʔωϯτͰ͍͘͠ճ͢ඞཁ͕͋ΔσʔλΛ֨ೲ → $store.dispatchΛݺΜͰɺaction -> commitͰͦͷ··storeʹ֨ೲͰ͖Δ
-> ΄΅ϫϯϥΠϯͰॻ͚Δ → جຊతʹࢀরͷΈͷσʔλͩͱɺ֤ίϯϙʔωϯτͰͷมߋʹΑΔίϯϑϦΫτ͕ى͜Γʹ͘͘ɺΑΓอकੑ͕ ߴ͘ͳΔ • ӬଓԽ͍ͨ͠σʔλʢvuex-persistedstateʣ → SPAͰɺॳظԽͷσʔλϑΣονͷ࣌ؒΛͰ͖Δ͚ͩॖ͍ͨ͠߹ -> [Local|Session]StorageʹೖΕ͓͍ͯͯɺ ࣍ճΞΫηε࣌ʹσϑΥϧτͰදࣔͰ͖ΔΑ͏ʹͰ͖Δ → ઃఆใͳͲɺAPIΛ࡞ͬͯαʔόͰӬଓԽ͢Δ΄ͲͰͳ͍ͷͰɺLocalStorageӬଓԽ͓ͯ͘͠ͱศར ͜Ε͚ͩʹ͠·͠ΐ͏ʂʂʂ
·ͱΊ StoreύλʔϯΛਖ਼͍͘͜͠ͳͯ͠ UXͷ༏ΕͨΞϓϦΛ࡞Ζ͏ʂ