Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

jsarnowski / jsarnowski/jet-smart-filters   php

Repository URL to install this package:

Version: 2.2.1 

/ src / js / includes / event-bus.js

export default {
	channels: {},

	subscribe(channelName, listener) {
		if (!this.channels[channelName]) {
			this.channels[channelName] = [];
		}
		this.channels[channelName].push(listener);
	},

	publish(channelName) {
		const channel = this.channels[channelName]
		if (!channel || !channel.length) {
			return;
		}

		channel.forEach(listener => listener(...Array.from(arguments).splice(1)));
	}
}