当前位置:网站首页>Anti shake and throttling
Anti shake and throttling
2022-04-23 08:05:00 【Pen drawing Acacia】
Shake proof : The problem to be solved is when an event is triggered multiple times within a time interval , It's only going to be executed once
throttle : The solution is to reduce the trigger frequency for a period of time
1: The function will only trigger once in a specified time , Specific implementation method
When the function is triggered for the first time , Delay delay Time execution , If in delay The function is triggered again within a time period , Then start over
timing
If delay The function is not triggered within the time period , Then execute the function
function bunde(fn ,depaly)
{
let timetar=null;
return function()
{
if(timetar)
{
clearTimeout(timetar);
}
timetar=setTimeout(fn,depaly);
}
}
throttle :
The problem with anti shake is , Continuously trigger events in a short time , Callback functions never execute .
The idea of saving money : Continuously trigger events in a short time , The callback function will only execute within the specified interval .
function throttle(fn, delay) {
let timer = null;
return function() {
if (timer) return false
timer = setTimeout(() => {
fn()
timer = null
}, delay)
}
}

版权声明
本文为[Pen drawing Acacia]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230624332804.html
边栏推荐
- ABAP ALV显示金额与导出金额不一致
- Buctf MISC brossage
- Mysql database backup and recovery under Linux (full + incremental)
- NLLLoss+log_SoftMax=CE_Loss
- SAP Query增强开发介绍
- Upload labs range practice
- Research on system and software security (2)
- 使用 Ingress 实现金丝雀发布
- C smoothprogressbar custom progress bar control
- CTF-MISC学习之从开始到放弃
猜你喜欢
![[NLP notes] preliminary study on CRF principle](/img/8c/2717aeee2e75bdae97d2bacd362e53.png)
[NLP notes] preliminary study on CRF principle

STO With Billing 跨公司库存转储退货

內網滲透系列:內網隧道之icmpsh

使用 Ingress 实现金丝雀发布

Intranet penetration series: icmptunnel of Intranet tunnel (by master dhavalkapil)

How does Apache Hudi accelerate traditional batch mode?

云计算技能大赛 -- openstack私有云环境 第二部分

随笔(不定时更新)

The displayed amount of ABAP ALV is inconsistent with the exported amount

Buctf MISC brossage
随机推荐
一些靶场的学习记录:sqli-labs、upload-labs、XSS
访问数据库的时候出现错误 Operation not allowed for a result set of type ResultSet.TYPE_FORWARD_ONLY.详解
Link to some good tutorials or notes about network security and record them
Intranet penetration series: icmptunnel of Intranet tunnel (Master James Barlow's)
SAP GUI安全性
Research on software security based on NLP (I)
求3个字符串(每串不超过20个字符)中的最大者。
NLLLoss+log_SoftMax=CE_Loss
feign如何集成hystrix
CTF-MISC学习之从开始到放弃
Export all SVG files in the specified path into pictures in PNG format (thumbnail or original size)
内网渗透系列:内网隧道之pingtunnel
Search and replacement of C text file (WinForm)
Using lambda expression to solve the problem of C file name sorting (whether it is 100 or 11)
linux下mysql数据库备份与恢复(全量+增量)
How to present your digital portfolio: suggestions from creative recruiters
《内网安全攻防:渗透测试实战指南》读书笔记(五):域内横向移动分析及防御
Buuctf misc brush questions
Complete color conversion formulas and conversion tables (31 kinds)
第四章 无形资产