Skip to main content
Module

x/evt/test/test44.ts

💧EventEmitter's typesafe replacement
Go to Latest
File
import { Evt } from "../lib/index.ts";

const evtText = new Evt<"TICK" | "END" >();
let acc= "";
const ctx = Evt.newCtx();
evtText.$attach( (text, registerSideEffect) => (text === "END" && registerSideEffect(() => ctx.done()), [text]), ctx, text=> acc += " " + text);
evtText.post("TICK");evtText.post("TICK");evtText.post("END");evtText.post("TICK");
console.assert(acc === " TICK TICK END");
console.log("PASS");