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
Amazon Bedrock Knowledge Bases Hands-on
konny0311
0
130
歴史から学ぶ「Why PHP?」 PHPを書く理由を改めて理解する / Learning from History: “Why PHP?” Rediscovering the Reasons for Writing PHP
seike460
PRO
0
140
TransformerからMCPまで(現代AIを理解するための羅針盤)
mickey_kubo
7
6.1k
Tangible Code
chobishiba
3
500
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
250
SUZURIの規約違反チェックにおけるクリエイタフィードバックの試⾏錯誤/Trial and Error in Creator Feedback for SUZURI's Terms of Service Violation Checks
ae14watanabe
1
130
ノーコードからの脱出 -地獄のデスロード- / Escape from Base44
keisuke69
0
650
Kotlin 2.2が切り拓く: コンテキストパラメータで書く関数型DSLと新しい依存管理のかたち
knih
0
380
Introducing RemoteCompose: break your UI out of the app sandbox.
camaelon
2
510
マイベストのシンプルなデータ基盤の話 - Googleスイートとのつき合い方 / mybest-simple-data-architecture-google-nized
snhryt
0
140
Eloquentを使ってどこまでコードの治安を保てるのか?を新人が考察してみた
itokoh0405
0
3.1k
React Nativeならぬ"Vue Native"が実現するかも?_新世代マルチプラットフォーム開発フレームワークのLynxとLynxのVue.js対応を追ってみよう_Vue Lynx
yut0naga1_fa
2
2.1k
Featured
See All Featured
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
660
Fireside Chat
paigeccino
41
3.7k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Making Projects Easy
brettharned
120
6.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Optimizing for Happiness
mojombo
379
70k
It's Worth the Effort
3n
187
28k
Testing 201, or: Great Expectations
jmmastey
46
7.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Into the Great Unknown - MozCon
thekraken
40
2.1k
Docker and Python
trallard
46
3.6k
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 を制する