Contents
- Welcome to Domma Reactive
- 01 Getting started
- 02 Reactive state
- 03 HTML and bindings
- 04 Components
- 05 Reference
Extenders and rate limiting
Updated by Darryl Waterhouse on 17 October 2026 · 1 min read
Extenders
.extend({…}) layers behaviour onto an observable after it exists, as Knockout's does.
const query = observable('').extend({rateLimit: 300});
query.value = 'a';
query.value = 'ab'; // one notification, 300ms after the typing stops
query.value; // 'ab' - the WRITE is never delayed, only the notification
| Extender | Value | Effect |
|---|---|---|
rateLimit |
ms, or {timeout, method} |
hold notifications; method is 'notifyWhenChangesStop' (default) or 'notifyAtFixedRate' |
throttle |
ms | Knockout's older name for rateLimit |
notify |
'always' |
announce every write, including one the change gate would swallow |
The two rate-limit methods differ in what the window measures. notifyWhenChangesStop measures quiet - the window
restarts on every change, so continuous typing announces nothing until it stops. notifyAtFixedRate measures elapsed
time - the deadline is set by the first change of a burst and does not move, so a continuous stream announces once per
window. Neither ever delivers a stale value.
Knockout's original throttle delayed the write, which is why reading a throttled observable used to return a value
that was already out of date, and why Knockout deprecated it. That is not repeated here: the name is accepted and given
rateLimit's behaviour. A write always lands immediately, whatever is extended onto it.
rateLimit uses a timer, not the graph's microtask flush, so flushSync() does not deliver a held notification - a
test advances its own clock. Extending twice reconfigures the one limiter rather than nesting a second inside it, and
.extend({rateLimit: 0}) switches it off, dropping anything already waiting.
registerExtender(name, fn) adds your own. The handler is given a control surface with exactly two powers -
setEquals(fn) to replace the change gate and intercept(wrap) to wrap the announcement - and no way to touch the
stored value, which is what keeps the guarantee above true of every extender, including yours.
import {registerExtender} from 'domma-reactive';
registerExtender('trace', (control, label) => {
control.intercept(next => (value) => {
console.log(label, value);
next(value);
});
});
const count = observable(0).extend({trace: 'count'});