公告:所有在
2025 年 4 月 15 日之前注册使用 Earth Engine 的非商业项目都必须
验证是否符合非商业性质的资格条件,才能继续使用 Earth Engine。
ui.util.throttle
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
封装一个函数,使其在每个时间间隔内最多可被调用两次。如果在延迟时间结束之前多次调用封装函数,则只有第一次和最后一次调用会通过。
使用示例:用于 ui.Slider 上滑动事件的回调。回调将立即运行,使滑动操作感觉响应迅速。该回调还保证在用户完成与滑块的互动后运行,从而确保最终回调调用可以访问滑块的最终值。
返回封装的函数。
用法 | 返回 |
---|
ui.util.throttle(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\u003eLimits a function's execution to at most twice per specified interval, ensuring responsiveness and capturing the final state.\u003c/p\u003e\n"],["\u003cp\u003eUseful for scenarios like UI slider events where immediate feedback and final value processing are crucial.\u003c/p\u003e\n"],["\u003cp\u003eWraps the original function and returns a new function that manages the throttling behavior.\u003c/p\u003e\n"],["\u003cp\u003eCustomizable with a delay parameter (in milliseconds) and an optional scope for execution context.\u003c/p\u003e\n"]]],[],null,["# ui.util.throttle\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, twice per interval. If the wrapper function is called multiple times before the delay elapses, only the first and the last calls will go through.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a slide event on a ui.Slider. The callback will run immediately, making the slide action feel responsive. The callback is also guaranteed to run after the user has finished interacting with the slider, ensuring that the final callback invocation has access to the slider's final value.\n\nReturns the wrapped function.\n\n| Usage | Returns |\n|--------------------------------------------|----------|\n| `ui.util.throttle(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | The function to call. |\n| `delay` | Number | The delay, in milliseconds, for the throttle. The function can only be called once after the initial invocation until after the delay has elapsed. |\n| `scope` | Object, optional | The object in whose scope to call the function. |"]]