You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs.md
+8-7Lines changed: 8 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ Additionally, there are the following extra options:
124
124
-`disableOnNoListeners` - whether to disable the SelectorObserver when there are no listeners left (defaults to false)
125
125
-`enableOnAddListener` - whether to enable the SelectorObserver when a new listener is added (defaults to true)
126
126
-`defaultDebounce` - if set to a number, this debounce will be applied to every listener that doesn't have a custom debounce set (defaults to 0)
127
-
-`defaultDebounceEdge` - can be set to "falling" (default) or "rising", to call the function at (rising) on the very first call and subsequent times after the given debounce time or (falling) the very last call after the debounce time passed with no new calls - [see `debounce()` for more info and a diagram](#debounce)
127
+
-`defaultDebounceType` - can be set to "immediate" (default), to call the function on the very first call and subsequent times after the given debounce time passed, or "idle", to let through the very last call, after the debounce time passed with no subsequent calls - [see `Debouncer` for more info and a diagram](#debouncer)
128
128
-`checkInterval` - if set to a number, the checks will be run on interval instead of on mutation events - in that case all MutationObserverInit props will be ignored
129
129
130
130
⚠️ Make sure to call `enable()` to actually start observing. This will need to be done after the DOM has loaded (when using `@run-at document-end` or after `DOMContentLoaded` has fired) **and** as soon as the `baseElement` or `baseElementSelector` is available.
@@ -154,8 +154,9 @@ The listener will be called immediately if the selector already exists in the DO
154
154
> If `options.debounce` is set to a number above 0, this listener will be debounced by that amount of milliseconds (defaults to 0).
155
155
> E.g. if the debounce time is set to 200 and the selector is found twice within 100ms, only the last call of this listener will be executed.
156
156
157
-
> `options.debounceEdge` is set to "falling" by default, which means the debounce timer will start after the last call of this listener.
158
-
> If set to "rising", the debounce timer will start after the first call of this listener.
157
+
> `options.debounceType` is set to "immediate" by default, which means the listener will be called immediately and then debounced on subsequent calls.
158
+
> If set to "idle", the SelectorObserver will wait until the debounce time has passed with no new calls and then calls the listener with the latest element(s) found.
159
+
> See the [Debouncer](#debouncer) class for a better explanation.
159
160
160
161
> When using TypeScript, the generic `TElement` can be used to specify the type of the element(s) that this listener will return.
161
162
> It will default to HTMLElement if left undefined.
// debounce all listeners by 100ms unless specified otherwise:
243
244
defaultDebounce: 100,
244
-
// "rising" means listeners are called immediately and use the debounce as a timeout between subsequent calls - see the debounce() function for a better explanation
245
-
defaultDebounceEdge: "rising",
245
+
// "immediate" means listeners are called immediately and use the debounce as a timeout between subsequent calls - see the Debouncer class for a better explanation
246
+
defaultDebounceType: "immediate",
246
247
// other settings from the MutationObserver API can be set here too - see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver/observe#options
0 commit comments