お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、Earth Engine へのアクセスを維持するために
非商用目的での利用資格を確認する必要があります。
ui.util.rateLimit
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
関数をラップして、インターバルごとに最大 1 回呼び出せるようにします。ラッパー関数が複数回呼び出された場合、最初の呼び出しのみが実行され、間隔が経過するまで後続の呼び出しは有効になりません。これは、実行にコストがかかる関数がすぐに実行され、繰り返し実行されないようにするために使用できます。
使用例: ui.Button のクリックに対するコールバックで、ボタンが誤ってダブルクリックされ、コールバックが 2 回実行されるのを防ぐため。
レート制限された関数を返します。
用途 | 戻り値 |
---|
ui.util.rateLimit(func, delay, scope) | 関数 |
引数 | タイプ | 詳細 |
---|
func | 関数 | 呼び出す関数。 |
delay | 数値 | 関数が呼び出されて実行された後、関数の追加の呼び出しを許可するまでの遅延時間(ミリ秒単位)。 |
scope | オブジェクト、省略可 | 関数を呼び出すスコープ内のオブジェクト。 |
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
[null,null,["最終更新日 2025-07-26 UTC。"],[[["\u003cp\u003eLimits a function's execution to at most once per specified interval, preventing rapid, repeated calls.\u003c/p\u003e\n"],["\u003cp\u003eUseful for optimizing expensive functions or preventing unintended double-click actions, such as on UI buttons.\u003c/p\u003e\n"],["\u003cp\u003eReturns a rate-limited version of the original function, accepting the function, delay, and optional scope as parameters.\u003c/p\u003e\n"],["\u003cp\u003eUtilizes a delay mechanism to ensure subsequent calls are ignored until the interval has elapsed, guaranteeing controlled execution.\u003c/p\u003e\n"]]],[],null,["# ui.util.rateLimit\n\n\u003cbr /\u003e\n\nWraps a function to allow it to be called, at most, once per interval. If the wrapper function is called more than once, only the first call will go through, and no subsequent invocations will have an effect until the interval has elapsed. This can be used to ensure a function that is expensive to run executes immediately but doesn't execute repeatedly.\n\n\u003cbr /\u003e\n\nExample use: For the callback to a click on a ui.Button, in order to prevent the button from being accidentally double-clicked and the callback running twice.\n\nReturns the rate-limited function.\n\n| Usage | Returns |\n|---------------------------------------------|----------|\n| `ui.util.rateLimit(func, delay, `*scope*`)` | Function |\n\n| Argument | Type | Details |\n|----------|------------------|------------------------------------------------------------------------------------------------------------------------------------------|\n| `func` | Function | Function to call. |\n| `delay` | Number | After the function is called and executed, the number of milliseconds to delay before allowing an additional invocation of the function. |\n| `scope` | Object, optional | Object in whose scope to call the function. |"]]