$ npm install @projectsophon/eventsThis package contains a typed, single pub/sub pattern used in the Dark Forest game. Inspired by https://www.npmjs.com/package/monomitter
You can install this package using npm or
yarn by running:
npm install --save @projectsophon/events
yarn add @projectsophon/events
When using this in a plugin, you might want to load it with skypack
import * as events from 'http://cdn.skypack.dev/@projectsophon/events'
Ƭ Callback<T>: (data: T) => Promise<void> | void
| Name |
|---|
T |
▸ (data): Promise<void> | void
| Name | Type |
|---|---|
data | T |
Promise<void> | void
Ƭ Monomitter<T>: Object
| Name |
|---|
T |
| Name | Type |
|---|---|
clear | () => void |
publish | (data: T) => Promise<void> |
subscribe | (cb: Callback<T>) => { unsubscribe: () => void } |
Ƭ Subscription<T>: (data: T) => Promise<void> | void
| Name |
|---|
T |
▸ (data): Promise<void> | void
| Name | Type |
|---|---|
data | T |
Promise<void> | void
Ƭ Unsubscribe: () => void
▸ (): void
void
▸ monomitter<T>(): Monomitter<T>
Constructs a new event emitter, whose purpose is to emit values of the given type.
| Name |
|---|
T |
Monomitter<T>