Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vue 3.0 Composition API を利用した Store と Composabl...
Search
Toru Eguchi
December 11, 2019
Technology
3
4.7k
Vue 3.0 Composition API を利用した Store と Composables の違い
Toru Eguchi
December 11, 2019
Tweet
Share
More Decks by Toru Eguchi
See All by Toru Eguchi
Vue 3.0 Composition API に触ってみた
egurinko
3
1.6k
このタイミングで Vue.js に TypeScript を導入するには?
egurinko
1
1.9k
How to start making a VR application with Unity
egurinko
0
57
Other Decks in Technology
See All in Technology
OCI Oracle Database Services新機能アップデート(2025/09-2025/11)
oracle4engineer
PRO
0
100
ガバメントクラウド利用システムのライフサイクルについて
techniczna
0
190
Kiro Autonomous AgentとKiro Powers の紹介 / kiro-autonomous-agent-and-powers
tomoki10
0
380
Gemini でコードレビュー知見を見える化
zozotech
PRO
1
240
regrowth_tokyo_2025_securityagent
hiashisan
0
210
Debugging Edge AI on Zephyr and Lessons Learned
iotengineer22
0
160
Lessons from Migrating to OpenSearch: Shard Design, Log Ingestion, and UI Decisions
sansantech
PRO
1
110
生成AIでテスト設計はどこまでできる? 「テスト粒度」を操るテーラリング術
shota_kusaba
0
660
ChatGPTで論⽂は読めるのか
spatial_ai_network
2
2.2k
AWS Bedrock AgentCoreで作る 1on1支援AIエージェント 〜Memory × Evaluationsによる実践開発〜
yusukeshimizu
6
380
[CMU-DB-2025FALL] Apache Fluss - A Streaming Storage for Real-Time Lakehouse
jark
0
110
技術以外の世界に『越境』しエンジニアとして進化を遂げる 〜Kotlinへの愛とDevHRとしての挑戦を添えて〜
subroh0508
1
430
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
97
6.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Side Projects
sachag
455
43k
The Language of Interfaces
destraynor
162
25k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Practical Orchestrator
shlominoach
190
11k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
Embracing the Ebb and Flow
colly
88
4.9k
Raft: Consensus for Rubyists
vanstee
141
7.2k
Context Engineering - Making Every Token Count
addyosmani
9
500
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Transcript
Vue 3.0 Composition API を利用した Store と Composables の違い 江口 徹(@egurinko)
Vue.js for 2020
• 大学 VR × 高齢者で研究 • 新卒で某通信会社 インフラ担当 • Code
Chrysalis という BootCamp を3ヶ月 • 某通信会社復帰 SIer としてフロント開発 • ギフティ入社半年 @egurinko (江口 徹)
お話しすること 01 02 03 04 Vue3.0 の疑問 Composition API の紹介
疑問解決への きっかけ まとめ
巷では、 • Composition API で 状態管理が出来るよう になる? 疑問の始まり
疑問の始まり LinusBorg 氏の demo を見ると、 同じ Composition API を利用した composables
と store が 存在する
どうやら、Composition API には、2 つの使い方がある この違いは一体なんなんだろう?
ということで、 試して、 探ってみた https://what-is-todays-dinner.herokuapp.com
https://what-is-todays-dinner.herokuapp.com ある特定の機能の Composition API の紹介
https://what-is-todays-dinner.herokuapp.com ある特定の機能の • 状態 Composition API の紹介
https://what-is-todays-dinner.herokuapp.com ある特定の機能の • 状態 • 振る舞い をモジュール化させるた めのAPI Composition API
の紹介
https://what-is-todays-dinner.herokuapp.com Composition API を利用する側 インポートして、関数を呼び出すだけ 各所で 使い回せば Store になる!
https://what-is-todays-dinner.herokuapp.com ますます、 Composables と Store の 違いがわからなくなっていた
ローダの機能をモジュール化した useLoader の composition function を実装した しかし、あるコンポーネントで Loader の State
を 変更しても、 Loader が回らない https://what-is-todays-dinner.herokuapp.com 違いに気づいたきっかけ
- App.vue - Recipes.vue - Loader.vue https://what-is-todays-dinner.herokuapp.com 原因 コンポーネントツリー useLoader()
で state の変更 useLoader() で state を参照
- App.vue - Recipes.vue - Loader.vue https://what-is-todays-dinner.herokuapp.com 原因 コンポーネントツリー useLoader()
で state の変更 useLoader() で state を参照 それぞれのスコープがグローバルではなかった・・・
https://what-is-todays-dinner.herokuapp.com 単純に作成した composition function のスコープは、 グローバルではない
https://what-is-todays-dinner.herokuapp.com 良く確認したら、 Linus さんの demo では、 Store として利用したい項目は provide でグローバルスコープへ
inject を利用して各コンポーネントで 利用するようになっていた store/ 配下
https://what-is-todays-dinner.herokuapp.com つまり、composables と store の境界とは グローバルで参照するべきものは、 composition api と provide/inject
を利用して store へ、 グローバルで必要のない状態や振る舞いは、 composables へ
https://what-is-todays-dinner.herokuapp.com 考えてみたら、 Store はグローバルで状態を管理したい って当たり前だよね
https://what-is-todays-dinner.herokuapp.com