@rbxts/task-event-emitter
v1.2.1
Published
Event emitter for roblox-ts using stravant's GoodSignal
Downloads
13
Readme
@rbxts/task-event-emitter
Event emitter for roblox-ts using stravant's GoodSignal class.
Installation
npm i @rbxts/task-event-emitter
Usage
Create an EventEmitter with an array of parameters:
const emitter = new EventEmitter<[player: Player]>(janitor);
Or, wrap an existing Roblox event:
const onChildAdded = EventEmitter.wrap(object.ChildAdded, janitor);
Example
import EventEmitter from "@rbxts/task-event-emitter";
const onChange = new EventEmitter<[property: string]>();
onChange.subscribe((property) => print(`Property ${property} changed!`));
onChange.emit("Name");
import EventEmitter from "@rbxts/task-event-emitter";
const emitter = new EventEmitter();
const subscription = emitter.subscribe(() => {});
if (!subscription.closed) {
subscription.unsubscribe();
}