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
throttleすげぇぇぇ
Search
Sigma
October 10, 2022
Programming
0
78
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
100
SSR+SPA
seiyasugimoto
0
130
Nuxtにおける設計
seiyasugimoto
0
89
Atomic Designを ディレクトリ以外で表現
seiyasugimoto
0
80
スマホでPythonしたい
seiyasugimoto
0
66
平文で保存するな!
seiyasugimoto
0
87
ソースコードを読もう
seiyasugimoto
0
85
Other Decks in Programming
See All in Programming
CSC509 Lecture 11
javiergs
PRO
0
300
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
360
contribution to astral-sh/uv
shunsock
0
590
What’s Fair is FAIR: A Decentralised Future for WordPress Distribution
rmccue
0
140
ノーコードからの脱出 -地獄のデスロード- / Escape from Base44
keisuke69
0
650
マンガアプリViewerの大画面対応を考える
kk__777
0
460
PyCon mini 東海 2025「個人ではじめるマルチAIエージェント入門 〜LangChain × LangGraphでアイデアを形にするステップ〜」
komofr
3
860
なんでRustの環境構築してないのにRust製のツールが動くの? / Why Do Rust-Based Tools Run Without a Rust Environment?
ssssota
15
48k
NIKKEI Tech Talk#38
cipepser
0
430
iOSでSVG画像を扱う
kishikawakatsumi
0
190
AI POSにおけるLLM Observability基盤の導入 ― サイバーエージェントDXインターン成果報告
hekuchan
0
400
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
6.1k
Featured
See All Featured
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
2
310
Writing Fast Ruby
sferik
630
62k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
The Invisible Side of Design
smashingmag
302
51k
Producing Creativity
orderedlist
PRO
348
40k
Being A Developer After 40
akosma
91
590k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
34
2.3k
A Tale of Four Properties
chriscoyier
161
23k
Docker and Python
trallard
46
3.6k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
660
Git: the NoSQL Database
bkeepers
PRO
431
66k
Statistics for Hackers
jakevdp
799
220k
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 を制する