Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@akkadu/importance-debounce

Package Overview
Dependencies
Maintainers
6
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@akkadu/importance-debounce

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

  • 4.1.2
  • latest
  • npm
  • Socket score

Version published
Maintainers
6
Created
Source

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)

// You should see the functions run in order of
// error => warn => resolved => info
// what is happening is that we are waiting for the default 2 seconds
// to toast each notification, and at each point we sort the next 
// item to be toasted according to it's priority and when it was added to the queue

FAQs

Package last updated on 20 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc