Skip to content

A JavaScript implement of NotificationQueue and NotificationCenter

Notifications You must be signed in to change notification settings

nilennoct/notification-queue

Repository files navigation

A JavaScript implement of NotificationQueue and NotificationCenter.

npm license travis FOSSA Status

Installation

yarn add notification-queue

# Or use npm
npm install notification-queue

Usage

NotificationCenter

import { NotificationCenter } from 'notification-queue';

const center = NotificationCenter.default;
const token = center.addObserver('update', null, (notification) => {
    console.log('Update:', notification.data);
});

center.post('update', null, 'Hello world!');

// Output "Update: Hello world!".

center.removeObserver(token);

NotificationQueue

import { Notification, NotificationCenter, NotificationQueue, PostingStyle } from 'notification-queue';

const center = NotificationCenter.default;
const queue = NotificationQueue.default;

const token = center.addObserver('update', null, (notification) => {
    console.log(notification.data);
});

queue.enqueue(Notification.init('update', null, 'X'), PostingStyle.asap);
queue.enqueue(Notification.init('update', null, 'Y'), PostingStyle.asap);

// Output "X".

API

See documents

License

FOSSA Status

About

A JavaScript implement of NotificationQueue and NotificationCenter

Resources

Stars

Watchers

Forks

Packages

No packages published