Skip to content

Commit e94812a

Browse files
committed
fixup: readme
Signed-off-by: Todd Baert <[email protected]>
1 parent 16f63c2 commit e94812a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

libs/hooks/debounce/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,16 @@ Simply wrap your hook with the debounce hook by passing it a constructor arg, an
2626
In the example below, we wrap the "after" stage of a logging hook so that it only logs a maximum of once a minute for each flag key, no matter how many times that flag is evaluated.
2727

2828
```ts
29-
// a function defining the key for the hook stage; if this matches a recent key, the hook execution for this stage will be bypassed
30-
const supplier = (flagKey: string, context: EvaluationContext, details: EvaluationDetails<T>) => flagKey;
31-
32-
const hook = new DebounceHook<string>(loggingHook, {
33-
debounceTime: 60_000, // how long to wait before the hook can fire again (applied to each stage independently) in milliseconds
34-
afterCacheKeySupplier: supplier, // if the key calculated by the supplier exists in the cache, the wrapped hook's stage will not run
29+
const debounceHook = new DebounceHook<string>(loggingHook, {
30+
debounceTime: 60_000, // how long to wait before the hook can fire again
3531
maxCacheItems: 100, // max amount of items to keep in the cache; if exceeded, the oldest item is dropped
36-
cacheErrors: false // whether or not to debounce errors thrown by hook stages
3732
});
33+
34+
// add the hook globally
35+
OpenFeature.addHooks(debounceHook);
36+
37+
// or at a specific client
38+
client.addHooks(debounceHook);
3839
```
3940

4041
## Development

0 commit comments

Comments
 (0)