Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Dat...

Avatar for konkarin konkarin
November 11, 2025

Vueで学ぶデータ構造入門 リンクリストとキューでリアクティビティを捉える / Vue Data Structures: Linked Lists and Queues for Reactivity

Vue Fes Japan 2025 After Talk https://yappli.connpass.com/event/368396/

Avatar for konkarin

konkarin

November 11, 2025
Tweet

More Decks by konkarin

Other Decks in Programming

Transcript

  1. 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の描画で起きること
  2. 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
  3. 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
  4. 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
  5. 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 満を持してキューが登場
  6. 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
  7. 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
  8. 再描画で起きること 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
  9. 再描画で起きること 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
  10. 再描画で起きること 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
  11. 再描画で起きること 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
  12. 再描画で起きること 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
  13. 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)の 計算量でリンクの追加削除ができる。