$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
throttleすげぇぇぇ
Search
Sigma
October 10, 2022
Programming
0
79
throttleすげぇぇぇ
Sigma
October 10, 2022
Tweet
Share
More Decks by Sigma
See All by Sigma
Proxmox_VE.pdf
seiyasugimoto
0
200
Stable Diffusionで遊んでみた
seiyasugimoto
1
130
EVAフレームワーク
seiyasugimoto
0
110
SSR+SPA
seiyasugimoto
0
140
Nuxtにおける設計
seiyasugimoto
0
91
Atomic Designを ディレクトリ以外で表現
seiyasugimoto
0
82
スマホでPythonしたい
seiyasugimoto
0
69
平文で保存するな!
seiyasugimoto
0
89
ソースコードを読もう
seiyasugimoto
0
87
Other Decks in Programming
See All in Programming
まだ間に合う!Claude Code元年をふりかえる
nogu66
5
890
Implementation Patterns
denyspoltorak
0
110
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
3
1.2k
re:Invent 2025 トレンドからみる製品開発への AI Agent 活用
yoskoh
0
130
「コードは上から下へ読むのが一番」と思った時に、思い出してほしい話
panda728
PRO
39
26k
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
170
Navigating Dependency Injection with Metro
l2hyunwoo
1
180
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.3k
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.4k
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
0
170
AIコーディングエージェント(skywork)
kondai24
0
200
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
56
14k
The Cult of Friendly URLs
andyhume
79
6.7k
Between Models and Reality
mayunak
0
150
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
410
Automating Front-end Workflow
addyosmani
1371
200k
VelocityConf: Rendering Performance Case Studies
addyosmani
333
24k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Paper Plane (Part 1)
katiecoart
PRO
0
1.9k
What the history of the web can teach us about the future of AI
inesmontani
PRO
0
370
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
28
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
210
Transcript
throttleがすごい話 Vueのリアクティブシステム
NLP のしぐまです! • 株式会社エヌエルプラスに去年入社しました。 ◦ リファラル採用やってます! • 自分はイベント配信プラットフォーム (受託) 等やってます。
• 現在は主にNuxtとGoとGCPを触っています。 ◦ フルスタックです!何でも屋とも言う…なぜかGoも触ってる… • シニアエンジニアです。
Vueのリアクティブシステム
変数の書き換えが速さがいやらしい場合 • 変数の書き換えに反応して重たい描画機能が走っている場合。書き換えの速さに よって死ぬ。 ◦ 経験したケースでは秒間数十回走るとつらい。 ◦ 高速なチャットとか。 • throttle
で書き換え回数を制限してしまえば安定するのではないか?
throttleの概要 • 関数の実行回数をNミリ秒に一回に制限できる。 ◦ 500 ミリ秒なら秒間 2 回 • Nミリ秒内の実行は無視されず、次の実行可能タイミングに実行される。
• lodashに入ってる
どう制限するか • ウォッチャに throttle で ラップした update 関数 を仕込み、更新回数の 制限された変数を実際
にその変数を描画する コンポーネントに渡す。 DRAW COMPONENT throttled variable: drawするコンポーネントへ渡 す。 update function: throttled variableを更新 watch: callback に throttle update function, 高速 で更新される store の変数を watch STORE
こんな感じ
lodash の throttle が優秀 • 公式ドキュメントから参照され ていた記事 https://css-tricks.com/debou ncing-throttling-explained-e xamples/
にあるデモを一部 throttle 用に書き換えた。
ユースケース(throttle, debounce) • 複数回の誤クリックの対策 • スクロールイベント等の制限 • リアクティブシステムの暴走を止める
イベント駆動な JavaScript を制する