A simple PubSub module for deno.
import { PubSub } from "https://deno.land/x/[email protected]/mod.ts";
class Test {
public x = "sfg";
}
const m = new PubSub();
m.subscribe(Test, (t) => {
// Prints: Test { x: "sfg" }
console.log(t);
});
m.publish(new Test());
m.subscribe(String, (s) => {
// Prints: sdfg
console.log(s);
});
m.publish("sdfg");
Licensed under the MIT License, checkout the LICENSE for more information.