PHP Classes

File: js/event-bus.js

Recommend this page to a friend!
  Classes of Rodrigo Faustino   Tamagoshi PHP Cryptocurrency Miner Virtual Pet   js/event-bus.js   Download  
File: js/event-bus.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Tamagoshi PHP Cryptocurrency Miner Virtual Pet
Game to manage a cryptocurrency miner pet
Author: By
Last change:
Date: 8 months ago
Size: 453 bytes
 

Contents

Class file image Download
class EventBus { constructor() { this.events = {}; } on(eventName, callback) { if (!this.events[eventName]) { this.events[eventName] = []; } this.events[eventName].push(callback); } emit(eventName, data) { if (this.events[eventName]) { this.events[eventName].forEach(callback => callback(data)); } } } const eventBus = new EventBus(); export default eventBus;