Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Dat...
Search
konkarin
November 11, 2025
Programming
1
390
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
890
普通のエンジニアが頑張って30万行のNuxt3移行した話 / Vue Fes Japan 2024 Nuxt3 version up
konkarin
4
4.5k
30万行を超えるCMSのNuxt3移行戦略 / Yappli tech conference 2023 Frontend
konkarin
0
62
Other Decks in Programming
See All in Programming
Media Capture and Streams: W3C仕様と現場での知見
nowaki28
0
130
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
5
18k
dnx で実行できるコマンド、作ってみました
tomohisa
0
130
Module Harmony
petamoriken
2
610
TypeScript 5.9 で使えるようになった import defer でパフォーマンス最適化を実現する
bicstone
1
1k
CSC509 Lecture 14
javiergs
PRO
0
220
Building AI Agents with TypeScript #TSKaigiHokuriku
izumin5210
6
1.2k
FluorTracer / RayTracingCamp11
kugimasa
0
180
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
210
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
130
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
170
sbt 2
xuwei_k
0
180
Featured
See All Featured
Embracing the Ebb and Flow
colly
88
4.9k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
285
14k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
700
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.3k
Context Engineering - Making Every Token Count
addyosmani
9
460
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Typedesign – Prime Four
hannesfritz
42
2.9k
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