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

@svelte-put/async-stack

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svelte-put/async-stack

type-safe and headless builder for async component stack

  • 0.0.0-next.1
  • next
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
30
increased by114.29%
Maintainers
0
Weekly downloads
 
Created
Source

@svelte-put/noti

npm.badge bundlephobia.badge docs.badge repl.badge

Type-safe and headless async notification builder

svelte-put

This package is part of the @svelte-put family. For contributing guideline and more, refer to its readme.

Usage & Documentation

See the dedicated documentation page here.

Quick Start

<script lang="ts">
  import { controller } from '@svelte-put/noti';

  // any Svelte component to render as notification
  import Notification from './Notification.svelte';

  // define somewhere global, reuse across app
  export const notiCtrl = controller()
    // add a minimalistic variant config
    .addVariant('info', Notification)
    // add a verbose variant config
    .addVariant('special', {
      timeout: false,
      id: 'counter',
      component: Notification,
      props: {
        // inferred from Notification component
        special: true,
        content: 'A very special notification',
      },
    })
    // build the actual NotificationController
    .build();

  onMount(async () => {
    // push a special notification
    const pushed = notiStore.push('special');

    // wait for some user action for the notification
    // to be resolved (popped) from within the component
    const { userAction } = await pushed.resolution;

    // push another notification with custom props
    notiStore.push('info', {
      props: {
        content: 'An example information',
      },
    });
  });
</script>

<!-- notification portal, typically setup at somewhere global like root layout -->
<aside class="applicable class">
  {#each notiCtrl.notifications as notification (notification.config.id)}
    <div use:notiCtrl.actions.render={notification}>
      <!-- notification instances rendered as direct children -->
    </div>
  {/each}
</aside>

Changelog

Keywords

FAQs

Package last updated on 22 Jun 2024

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