Skip to content

javierlopezdeancos/laguagua

Repository files navigation

logo

Another typescript bus event.

Activity

License GitHub issues GitHub all releases GitHub Workflow Status npm

Why?

Why not.

Install

npm i laguagua --save

Usage

Import

import { laGuaGua as bus } from 'laguagua';

Interface

Review and use to your implementations how the Laguagua interface looks

export interface ILaGuaGua {
  publish: (message: string, data?: Object) => void;
  subscribe: (message: string, trigger: Handler) => void;
  clear: () => void;
}

Publish

publish an event message.

bus.publish('bus::stop');

Subscribe

Subscribe into an event message.

const eventHandler = (message, data) => console.log(message);
bus.subscribe('bus::stop', eventHandler);

Clear

Clear all bus subscriptions.

bus.clear();