-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
43a4cdb
commit d9f1c1d
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Debouncing | ||
|
||
Debouncing a job implies delaying and deduplicating it. | ||
|
||
```typescript | ||
import { Queue } from 'bullmq'; | ||
|
||
const myQueue = new Queue('Paint'); | ||
|
||
// Add a job that will be debounced for 5 seconds. | ||
await myQueue.add('house', { color: 'white' }, { debouncedId: 'customValue', delay: 5000 }); | ||
``` | ||
|
||
For the next 5 seconds, after adding this job, next jobs added with same **debouncedId** will be ignored and a _debounced_ event will be triggered by our QueueEvent class. | ||
|
||
Note that apart of passing a delay value, you must provide a debouncedId that should represent your job. You can hash your entire job data or a subset of attributes for creating a debouncedId. | ||
|
||
{% hint style="warning" %} | ||
Passing `debouncedId` without a `delay` value greater than 0 will throw an Error. | ||
{% endhint %} | ||
|
||
## Read more: | ||
|
||
* 💡 [Add Job API Reference](https://api.docs.bullmq.io/classes/v5.Queue.html#add) |