1.0.1 • Published 6 years ago

notification-queue v1.0.1

Weekly downloads
16
License
MIT
Repository
github
Last release
6 years ago

A JavaScript implement of NotificationQueue and NotificationCenter.

Installation

FOSSA Status

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

1.0.1

6 years ago

1.0.0

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago