Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
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
110
SSR+SPA
seiyasugimoto
0
130
Nuxtにおける設計
seiyasugimoto
0
90
Atomic Designを ディレクトリ以外で表現
seiyasugimoto
0
80
スマホでPythonしたい
seiyasugimoto
0
66
平文で保存するな!
seiyasugimoto
0
87
ソースコードを読もう
seiyasugimoto
0
85
Other Decks in Programming
See All in Programming
JEP 496 と JEP 497 から学ぶ耐量子計算機暗号入門 / Learning Post-Quantum Crypto Basics from JEP 496 & 497
mackey0225
2
550
目的で駆動する、AI時代のアーキテクチャ設計 / purpose-driven-architecture
minodriven
11
3.8k
ViewファーストなRailsアプリ開発のたのしさ
sugiwe
0
350
WebRTC と Rust と8K 60fps
tnoho
2
1.8k
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
440
【レイトレ合宿11】kagayaki_v4
runningoutrate
0
210
Socio-Technical Evolution: Growing an Architecture and Its Organization for Fast Flow
cer
PRO
0
200
しっかり学ぶ java.lang.*
nagise
1
470
無秩序からの脱却 / Emergence from chaos
nrslib
2
11k
非同期処理の迷宮を抜ける: 初学者がつまづく構造的な原因
pd1xx
1
400
全員アーキテクトで挑む、 巨大で高密度なドメインの紐解き方
agatan
8
18k
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
380
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
700
Art, The Web, and Tiny UX
lynnandtonic
303
21k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.5k
Learning to Love Humans: Emotional Interface Design
aarron
274
41k
Speed Design
sergeychernyshev
33
1.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
690
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.6k
Git: the NoSQL Database
bkeepers
PRO
432
66k
The Language of Interfaces
destraynor
162
25k
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 を制する