Socket
Socket
Sign inDemoInstall

notificationsjs

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    notificationsjs

Coming soon...


Version published
Maintainers
1
Created

Readme

Source

Notifications.js

Coming soon...

API


var pusher = new Pusher(...);

var notifications = new Notifications({
  // where to place notifications
  targetDOMElement: '#notifications',

  // close after X millseconds
  closeAfter: 5000,

  // how many notifications to show at once:
  showMax: 5,

  // array of classes to give each notification
  notificationClasses: ['my-notification'],

  // function called when a message is closed
  onClose: function(message) {...}

  // function called when a new message is shown
  onShow: function(message) {...}


  // optional, but if set will render notifications from events on a Pusher channel
  pusher: {
    instance: pusher,
    channelName: 'notifications',
    eventName: 'new-notification',
    // used to tell Notification.js what string to show in the notification, from the Pusher event
    // you could also return a DOM Element here instead
    transform: function(event) {
      return 'New message: ' + event.text;
    }
  }
});

// if you're not using Pusher, you'll get an API to send messages to:
// this will add the new message and immediately show it
notifications.push('This is a new message');

// general API

notifications.getLatest(); // get the latest message
notifications.getAll(); // get an array of all the messages
notifications.clear(); // remove all notifications

notifications.onNewMessage(function() {
  // do something when a new message is added
  // this will be useful for hooking into other libraries (React, etc)
});

FAQs

Last updated on 24 Apr 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc