evt.detach(ctx?)
Similar to EventEmitter.prototype.removeListener()
Returns
Parameters
Examples
const evtText = new Evt<string>();
//detach with no argument will detach all handlers (attach, attachOnce, waitFor... )
evtText.detach();import { Evt } from "evt";
const evtText = new Evt<string>();
evtText.attachOnce(text=> console.log(`Hello ${text}`));
const ctx = Evt.newCtx();
evtText.attach(
ctx,
_text => console.assert(false,"never")
);
evtText.attachOnce(
ctx,
_text => console.assert(false,"never")
);
evtText.detach(ctx);
//"Hello World" will be printed
evtText.post("World");Last updated
Was this helpful?