1.0.0-rc.1 • Published 4 years ago

br24-event v1.0.0-rc.1

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
4 years ago

@sep/br24-event

Install

yarn add @sep/br24-event

Usage

import EventManager, { Event } from '@sep/br24-event';

const em = new EventManager<Event.Database.Notification>({ topic: '<topic_name>' });

em.publish({
	channel: 'change',
	payload: {
		table: 'articles',
		action: 'UPDATE',
		newArticle: {
			// ...
		},
		oldArticle: {
			// ...
		},
	},
});

const subscription = em.subscribe('<subscription>', {
	flowControl: {
		allowExcessMessages: false,
		maxMessages: 3,
	},
});

subscription.on('message', (message) => {
	const payload = em.parse(message);

	// ...
});