JSFiddle - React, Tailwind, and code Playground

by Daedalus

JavaScript

class Chan {
	constructor(name) {
  	this.name = name;
  }
}

class cm {
	constructor() {
  	this.chans = [];
    this.name = '';
  }
  
  chan(name) {
  	if (typeof this.chans[name] === 'undefined') {
    	this.chans[name] = new Chan(name);
    }
    this.name = name;
    return this;
  }
  
  emit(evtName, listener) {
  	this.chans[this.name].name = {evtName, listener};
    return this;
  }
  
  on(evtName, listener) {
  	this.chans[this.name].name2 = {evtName, listener};
    return this;
  }
}

var blah = new cm();

blah.chan('blah').emit('blah2e', 'blah2l').on('blah3e', 'blah3l').chan('blah4').emit('blah5e', 'blah5l');
console.log(blah.chans);