1.0.2 • Published 1 year ago

multiplatform-events v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Multiplatform Events

Overview

A really (really) simple event system for every JS project. As in nodejs you can extends the MultiplatformEvents class to create your own event system. Then you will be able to use the on once off and emit methods to manage your events.

Installation

npm install multiplatform-events

Usage

Example 1

import MultiplatformEvents from 'multiplatform-events';
// or
const MultiplatformEvents = require('multiplatform-events');

const events = new MultiplatformEvents();
events.on('myEvent', (data) => {
	console.log(data);
});
events.emit('myEvent', 'Hello World !');
// Hello World !

Example 2

import MultiplatformEvents from 'multiplatform-events';
// or
const MultiplatformEvents = require('multiplatform-events');

class MyEvents extends MultiplatformEvents {
	constructor() {
		super();
	}

	myMethod() {
		this.emit('myEvent', 'Hello World !');
	}
}

const events = new MyEvents();
events.on('myEvent', (data) => {
	console.log(data);
});
events.myMethod();
// Hello World !
1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago