公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ui.util.debounce
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
封装一个函数,使其在重复触发的一系列调用中最多只能被调用一次,前提是这些调用的触发间隔时间(以毫秒为单位)小于指定的时间间隔。这可用于减少高开销函数的调用次数,同时确保该函数最终运行。
使用示例:用于 ui.Checkbox 上更改事件的回调。如果用户反复点击复选框,只有最后一次点击复选框才会运行回调。
返回去抖动后的函数。
用法 | 返回 |
---|
ui.util.debounce(func, delay, scope) | 函数 |
参数 | 类型 | 详细信息 |
---|
func | 函数 | 要去抖动的函数。 |
delay | 数字 | 在函数被调用一次后,再次调用该函数之前要延迟的毫秒数,然后才能运行该函数。 |
scope | 对象,可选 | 要在哪个范围中调用函数的对象。 |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eDebounces a function, limiting its execution to at most once within a specified time interval, even with repeated calls.\u003c/p\u003e\n"],["\u003cp\u003eUseful for optimizing expensive functions triggered by frequent events, ensuring only the last call within the interval is executed.\u003c/p\u003e\n"],["\u003cp\u003eReturns a debounced version of the original function, which can be called directly.\u003c/p\u003e\n"],["\u003cp\u003eCustomizable with parameters like \u003ccode\u003edelay\u003c/code\u003e for setting the debounce interval and \u003ccode\u003escope\u003c/code\u003e for controlling the function's execution context.\u003c/p\u003e\n"]]],[],null,["# ui.util.debounce\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, once for each sequence of calls fired repeatedly so long as they are fired less than a specified interval apart (in milliseconds). This can be used to reduce the number of invocations of an expensive function while ensuring it eventually runs.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a change event on a ui.Checkbox. If the user clicks the checkbox repeatedly, only the last click of the checkbox will run the callback.\n\nReturns the debounced function.\n\n| Usage | Returns |\n|--------------------------------------------|----------|\n| `ui.util.debounce(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | The function to debounce. |\n| `delay` | Number | After the function is called once, the number of milliseconds to delay for an additional invocation of the function before allowing it to run. |\n| `scope` | Object, optional | Object in whose scope to call the function. |"]]