@galatajs/events
v0.1.1
Published
Events package of galatajs framework
Downloads
7
Maintainers
Readme
What Is It?
Server Side Event Package. Do you want to do something in customer service when there is a record in the product table? That's called lifecycle and @galatajs/events
provides it.
You don't have to use galatajs
framework, @galatajs/events
is a nodejs package.
Installation
npm install @galatajs/events
or with yarn
yarn add @galatajs/events
Example
Take a look at the example folder for example usage!
Basic Usage
import { createEvent } from "@galatajs/events";
let totalPrice = 0;
const callback = (price : number) : void => {
totalPrice += price;
}
const onProductAddEvent = createEvent<number>("product-add");
onProductAddEvent.addListener(callback);
onProductAddEvent.publish(10);
onProductAddEvent.publish(20);
console.log(totalPrice); // 30
Although this explains the usage, the purpose of the package is more than that, please review the example folder for better usage.