0.0.3 • Published 3 years ago

@costadvl/school-bus v0.0.3

Weekly downloads
-
License
Apache License 2....
Repository
github
Last release
3 years ago

School Bus

Node.js CI

import { BusEmitter } from './emitter';
import { BusObserver } from './observer';
import { Static } from './static';

class Receiver extends BusObserver {
    constructor(id: string) {
        super(id);
    }
    notification(event: string, emitter: string, content: any) {
        console.log(...arguments);
    }
}

const mother = new Receiver('motherShip').observeEvent(['secret', 'mother']);
const planet = new Receiver('planet').observeEvent(['secret']);
const ship = new BusEmitter('ship');

Static.DefaultBus.registerObserver([mother, planet]);
ship.send('secret', { star: 'delilah', status: 'save' });
ship.send('mother', { star: 'delilah', status: 'save' });