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
Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Dat...
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
konkarin
November 11, 2025
Programming
1
580
Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Data Structures: Linked Lists and Queues for Reactivity
Vue Fes Japan 2025 After Talk
https://yappli.connpass.com/event/368396/
konkarin
November 11, 2025
Tweet
Share
More Decks by konkarin
See All by konkarin
Radix UIとArk UIを併用したマルチフレームワーク対応デザインシステムの道はあるか / multi-framework-designsystem-with-arkui-and-radixui
konkarin
2
1k
普通のエンジニアが頑張って30万行のNuxt3移行した話 / Vue Fes Japan 2024 Nuxt3 version up
konkarin
4
4.8k
30万行を超えるCMSのNuxt3移行戦略 / Yappli tech conference 2023 Frontend
konkarin
0
70
Other Decks in Programming
See All in Programming
浮動小数の比較について
kishikawakatsumi
0
320
AIに仕事を丸投げしたら、本当に楽になれるのか
dip_tech
PRO
0
150
CSC307 Lecture 09
javiergs
PRO
1
850
PostgreSQL を使った快適な go test 環境を求めて
otakakot
0
120
Go1.26 go fixをプロダクトに適用して困ったこと
kurakura0916
0
220
受け入れテスト駆動開発(ATDD)×AI駆動開発 AI時代のATDDの取り組み方を考える
kztakasaki
1
290
AI時代でも変わらない技術コミュニティの力~10年続く“ゆるい”つながりが生み出す価値
n_takehata
1
230
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
120
ふん…おもしれぇ Parser。RubyKaigi 行ってやるぜ
aki_pin0
0
110
CSC307 Lecture 11
javiergs
PRO
0
580
The Ralph Wiggum Loop: First Principles of Autonomous Development
sembayui
0
3.6k
Event Storming
hschwentner
3
1.3k
Featured
See All Featured
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
140
Imperfection Machines: The Place of Print at Facebook
scottboms
269
14k
Context Engineering - Making Every Token Count
addyosmani
9
680
Scaling GitHub
holman
464
140k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
610
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.6k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
230
Information Architects: The Missing Link in Design Systems
soysaucechin
0
800
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
0
440
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
42k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
160
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
140
Transcript
Vueで学ぶデータ構造⼊⾨ リンクリストとキューで リアクティビティを捉える Vue Fes Japan 2025 After Talk 2025.11.11
SPEAKER 株式会社ヤプリ プロダクト開発本部 フロントエンドグループ マネージャー こん てぃらの という猫と暮らしています。 かわいい
INDEX ⽬次 1. はじめに 2. リアクティビティの仕組みとデータ構造
はじめに
今⽇のターゲット • Vue使い慣れてアプリ作れるようになった⼈、Vue1〜3年⽬くらいの⼈ • Vueを探求したい⼈ • Chibivue(https://book.chibivue.land/ja/)やった⼈ できるだけ簡単に、概念に触れながら詳細は省くので、厳密には違う部分もあり ます。後⽇ブログで補完する予定です🙏
今⽇扱う内容
https://roadmap.sh/computer-science
https://roadmap.sh/computer-science 👉
⾔語選択の次がデータ構造 👇
今⽇扱うVueのバージョン • 現⾏の3.5 • 絶賛alphaの3.6
今⽇のお題コード
リアクティビティの仕組みと データ構造
リアクティビティの仕組みを知ろう おれ(たち?)は雰囲気でリアクティビティAPIを使っている。 リアクティビティAPI同⼠がどうつながっているか知ろう! ❓
今⽇のお題コード(再掲)
それぞれのAPIの特性 refとcomputedは値を持ち、誰かに参照される computedとwatchEffectとtemplateは値を参照する →依存元(Dep) →購読者(Sub)
それぞれのAPIの特性 refとcomputedは値を持ち、誰かに参照される computedとwatchEffectとtemplateは値を参照する →依存元(Dep) →購読者(Sub) computedはどちらの特性も持つ
例えばこのコードなら、watchEffectがrefを参照したときにLinkができる ⼀対のDepとSubでLinkが作られる ref x watchEffect Link
Linkはいっぱいあってお互い繋がってる Link2 Link1 Link3 Link4 広がるリアクティブの輪
Linkのデータ構造
Linkのデータ構造 前後のDepが持つLinkがわかる 前後のSubが持つLinkがわかる
Linkのデータ構造 前後のDepが持つLinkがわかる 前後のSubが持つLinkがわかる 前後がわかる=双⽅向 これが双⽅向リンクリスト (Doubly-Linked List)
補⾜)リンクリストの種類 次だけわかる単⽅向リンクリスト 前後がわかる双⽅向リンクリスト
次はリアクティビティの輪が 作られる過程を⾒ましょう☝
とても雑なVueの処理の流れ 1. setup (<script setup>)が実⾏ 2. コンポーネントが画⾯に描画(=mount) 3. なんやかんやでリアクティブな状態が更新 4.
コンポーネントが画⾯に再描画
今⽇のお題コード(再掲)
setupで起きること 1 1. refが宣⾔される。
setupで起きること 1 2. computedが宣⾔される。(計算はまだしない)
setupで起きること 1 3. watchEffectが実⾏されてrefを参照してLink1が作られる。 (watchEffectの引数は即実⾏される) ref x watchEffect Link1
1. templateの描画が開始。 templateの描画で起きること 2 ref x watchEffect Link1
2 2. templateがrefを参照してLink2が作られる。 Link1から⾒てLink2のtemplateはnextSub、逆はprevSub。 ref x watchEffect Link1 ref x
template Link2 nextSub prevSub templateの描画で起きること
2 3. templateがcomputedを参照してLink3が作られる。computedはここで算出 Link2から⾒てLink3のcomputedはnextDep、逆はprevDep。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 nextSub prevSub prevDep nextDep templateの描画で起きること
2 4. computedがrefを参照してLink4が作られる。 Link2から⾒てLink4のcomputedはnextSub、逆はprevSub ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link 4 nextSub prevSub nextSub prevSub prevDep nextDep templateの描画で起きること
これでsetupとtemplateの初期化終わり 次はリアクティブの更新!
refの更新で起きること 3 1. ボタンクリックでrefが更新される。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link4 nextSub prevSub nextSub prevSub prevDep nextDep
2. refの更新が末尾のLink4のSubに通知される。 refの更新で起きること 3 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link 4 nextSub prevSub nextSub prevSub prevDep nextDep
3. Link4からprevSubを辿って、先頭のLink1のSubが 実⾏する処理をキューに⼊れる。 refの更新で起きること 3 ref x watchEffect Link1 ref
x template Link2 computed x template Link3 ref x computed Link4 Queue Link1の処理 nextSub prevSub nextSub prevSub prevDep nextDep ref ref ref
3. Link4からprevSubを辿って、先頭のLink1のSubが 実⾏する処理をキューに⼊れる。 refの更新で起きること 3 ref x watchEffect Link1 ref
x template Link2 computed x template Link3 ref x computed Link4 Queue Link1の処理 nextSub prevSub nextSub prevSub prevDep nextDep ref ref ref 満を持してキューが登場
refの更新で起きること 3 4. Link2のSubが実⾏する処理をキューに⼊れる。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link4 Link2の処理 Queue Link1の処理 nextSub prevSub nextSub prevSub prevDep nextDep
refの更新で起きること 3 5. Link4のSubはcomputedなので後で実⾏する。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link 4 Queue Link2の処理 Link1の処理 nextSub prevSub nextSub prevSub prevDep nextDep
再描画で起きること 4 1. ⾮同期でキューを順番に実⾏する。 まずはwatchEffectが実⾏。 ref x watchEffect Link1 ref
x template Link2 computed x template Link3 ref x computed Link4 Queue Link2の処理 Link1の処理 nextSub prevSub nextSub prevSub prevDep nextDep
再描画で起きること 4 2. 次にtemplateの描画が再実⾏。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link4 Queue Link2の処理 nextSub prevSub nextSub prevSub prevDep nextDep
再描画で起きること 4 3. templateがLink2のDepのrefを参照する。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link4 Queue nextSub prevSub nextSub prevSub prevDep nextDep
再描画で起きること 4 4. templateがLink3のDepのcomputedを参照する。 ここでcomputedが再計算! ref x watchEffect Link1 ref
x template Link2 computed x template Link3 ref x computed Link4 Queue nextSub prevSub nextSub prevSub prevDep nextDep
再描画で起きること 4 5. なんやかんやでtemplateの再描画が終わる。 ref x watchEffect Link1 ref x
template Link2 computed x template Link3 ref x computed Link4 Queue nextSub prevSub nextSub prevSub prevDep nextDep
めでたしめでたし🎉
Link(リンクリスト)の何が嬉しいのか • Linkのデータ構造はVue 3.5から登場しました。3.6でも使われる予定。 ◦ Refactor reactivity system to use
version counting and doubly-linked list tracking #10397 ◦ ↑3.5でメモリ効率とパフォーマンスがめっちゃ良くなったPR。3.6で更に良くなる! • 誰がどこにどの順番で依存しているかわかる。 • リアクティブな状態の依存関係は変わりうるので、変わったときでもO(1)の 計算量でリンクの追加削除ができる。
仕組みがわかると⾯⽩い これからVueを書くとき、 「ここでLinkが作られてLinkを通してDepに通知されてSubが実⾏されて リアクティブになってるんだなぁ‧‧‧☺」 とVueの暖かみを感じられるはず。
今⽇扱ったデータ構造 リンクリストもキューも⾊んなフレームワークで使われてるよ。React, Svelte, Preact, … キューは割と使うと思いますが、 リンクリストは普通のWebフロントエンド開発ではほぼ使わないと思います。
FOLLOW ME!! Yappli Tech Blog Yappli Developers カジュアル⾯談 @yappli_dev https://tech.yappli.io/
https://open.talentio.com/r/1/c/yappli/pages/59642