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

toasterhea

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

toasterhea

Promise-driven toast poppin' library.

  • 1.0.0-beta.1
  • npm
  • Socket score

Version published
Weekly downloads
32
decreased by-31.91%
Maintainers
1
Weekly downloads
 
Created
Source

toasterhea 🍞

Promise-driven toast-poppin' library.

Installation

npm i toasterhea eventemitter3 lodash

Key elements

Container(props: { id: string } & …): JSX.Element

It's a React component responsible for rendering toastables.

import { Container } from 'toasterhea'

useDiscardableEffect(fn?: (discard: () => void | Promise<void>) => void): void

It's a React hook responsible for letting the Container know when exacly a toastable can be discarded. Everything you turn into a toast will have to utilize this hook.

Note that although the use of this hook is necessary, the callback is optional. If the callback isn't defined, the library will discard a toastable immediately after its promise is settled.

import { useDiscardableEffect } from 'toasterhea'

toaster<T>(component: T, containerId: string): Toaster<T>

It turns components into toastables returns two methods:

  1. async pop(props?: ComponentProps<T>) – displays the component using given props, and
  2. discard() which rejects the internal promise.
import { toaster, Toaster } from 'toasterhea'

Reason

Some rejection scenarios are predefined and either are used internally or can be used from the outside to control the flow.

  • Reason.Update

    Happens when the user calls pop on a toast that's already "popped" (got displayed). Any piece of code waiting for the previous call to pop will receive a rejection.

  • Reason.Unmount

    Happens when the Container itself gets unmounted. The library rejects all outstanding promises and removes their associated DOM elements.

  • Reason.Host

    Happens when Toaster<T>.discard is called.

import { Reason } from 'toasterhea'

Examples

TODO

Keywords

FAQs

Package last updated on 30 Mar 2023

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