公告:凡是在
2025 年 4 月 15 日前註冊使用 Earth Engine 的非商業專案,都必須
驗證非商業用途資格,才能繼續存取 Earth Engine。
ui.util.debounce
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
包裝函式,允許其在每次重複觸發的呼叫序列中最多呼叫一次,只要這些呼叫的觸發間隔小於指定間隔 (以毫秒為單位) 即可。這可用來減少昂貴函式的叫用次數,同時確保函式最終會執行。
用途範例:ui.Checkbox 的變更事件回呼。如果使用者重複點選核取方塊,只有最後一次點選核取方塊會執行回呼。
傳回去抖動函式。
用量 | 傳回 |
---|
ui.util.debounce(func, delay, scope) | 函式 |
引數 | 類型 | 詳細資料 |
---|
func | 函式 | 去抖動的函式。 |
delay | 數字 | 函式呼叫一次後,允許函式執行前,額外呼叫函式的延遲毫秒數。 |
scope | 物件 (選用) | 要在哪個範圍內呼叫函式的物件。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-11 (世界標準時間)。
[null,null,["上次更新時間:2025-08-11 (世界標準時間)。"],[[["\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. |"]]