Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/littensy/event-emitter
Event emitter for roblox-ts
https://github.com/littensy/event-emitter
Last synced: 30 days ago
JSON representation
Event emitter for roblox-ts
- Host: GitHub
- URL: https://github.com/littensy/event-emitter
- Owner: littensy
- License: mit
- Created: 2021-08-08T04:49:59.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-11T21:35:53.000Z (about 2 years ago)
- Last Synced: 2023-03-18T10:32:54.136Z (almost 2 years ago)
- Language: Lua
- Size: 214 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @rbxts/task-event-emitter
Event emitter for roblox-ts using [stravant's GoodSignal class](https://devforum.roblox.com/t/lua-signal-class-comparison-optimal-goodsignal-class/1387063).
## Installation
```
npm i @rbxts/task-event-emitter
```## Usage
Create an EventEmitter with an array of parameters:
```ts
const emitter = new EventEmitter<[player: Player]>(janitor);
```Or, wrap an existing Roblox event:
```ts
const onChildAdded = EventEmitter.wrap(object.ChildAdded, janitor);
```## Example
```ts
import EventEmitter from "@rbxts/task-event-emitter";const onChange = new EventEmitter<[property: string]>();
onChange.subscribe((property) => print(`Property ${property} changed!`));
onChange.emit("Name");
``````ts
import EventEmitter from "@rbxts/task-event-emitter";const emitter = new EventEmitter();
const subscription = emitter.subscribe(() => {});
if (!subscription.closed) {
subscription.unsubscribe();
}
```