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.8k
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
Python 3.14 Overview
lycorptech_jp
PRO
1
120
Microsoft Agent 365 についてゆっくりじっくり理解する!
skmkzyk
0
390
Reinforcement Fine-tuning 基礎〜実践まで
ch6noota
0
190
regrowth_tokyo_2025_securityagent
hiashisan
0
260
re:Invent2025 コンテナ系アップデート振り返り(+CloudWatchログのアップデート紹介)
masukawa
0
390
ペアーズにおけるAIエージェント 基盤とText to SQLツールの紹介
hisamouna
0
420
エンジニアリングをやめたくないので問い続ける
estie
2
1.2k
日本Rubyの会: これまでとこれから
snoozer05
PRO
4
160
Bedrock AgentCore Memoryの新機能 (Episode) を試してみた / try Bedrock AgentCore Memory Episodic functionarity
hoshi7_n
1
480
5分で知るMicrosoft Ignite
taiponrock
PRO
0
400
20251219 OpenIDファウンデーション・ジャパン紹介 / OpenID Foundation Japan Intro
oidfj
0
190
2025-12-18_AI駆動開発推進プロジェクト運営について / AIDD-Promotion project management
yayoi_dd
0
120
Featured
See All Featured
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
110
ラッコキーワード サービス紹介資料
rakko
0
1.7M
Writing Fast Ruby
sferik
630
62k
A better future with KSS
kneath
240
18k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
85
For a Future-Friendly Web
brad_frost
180
10k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
Done Done
chrislema
186
16k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
0
91
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