Description
The point of this helper module is to provide a prioritized queue system
for notifications and making sure that we don't spam the user with notifications all the time
even if one type of event fires many times in a row.
The output of the system is an emit to which we can react in any way we want
Features:
- Queue up items and fire them on a schedule
- We use minimumToastTime to define how often we remove items from the queue and emit them to the user
- Don't spam the user with multiple notifications of the same type at once.
- We use a cooldown time set by frequencyTimeLimit, which limits how often a notification can fire
- Make sure that each notification has at least some time before being replaced by another
- We use minimumToastTime to make sure we don't constantly change the notification
- Allow priority notifications go ahead others
- We have 4 levels of priority: error, warn, resolved and info where error will always
fire before warning, which will always fire before resolved regardless when they were added to the queue
How to use
import importanceDebounce from '@akkadu/importance-debounce'
const infoCallback = ()=>console.log('Info')
const resolvedCallback = ()=>console.log('Resolved')
const warnCallback = ()=>console.warn('Warning')
const errorCallback = ()=>console.error('Error')
importanceDebounce('info-id', 'info', infoCallback)
importanceDebounce('resolved-id', 'resolved', resolvedCallback)
importanceDebounce('warn-id', 'warn', warnCallback)
importanceDebounce('error-id', 'error', errorCallback)