0.0.7 • Published 4 years ago
geso v0.0.7
geso
Global event standard output.
import { bus } from "geos"
// simple usage
bus.on(x => console.log(x));
bus.signal("sync emit");
await bus.emit("async emit");
// usage with filters
const numberBus = bus.where<number>(x => typeof x == 'number');
numberBus.on(x => console.log(x * 2));
numberBus.where(x=> x > 10).on(x => console.log("More than 10"));
numberBus.signal(4);
// nested bus
const privBus = new Bus();
numberBus.on(x=> privBus.emit(x));
// or
numberBus.pipe(privBus);