@projectsophon/events
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@projectsophon/events

This package contains a typed, single pub/sub pattern used in the Dark Forest game. Inspired by https://www.npmjs.com/package/monomitter

Installation

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'

Table of contents

Classes

Type Aliases

Functions

Type Aliases

Callback

Ƭ Callback<T>: (data: T) => Promise<void> | void

Type parameters

Name
T

Type declaration

▸ (data): Promise<void> | void

Parameters
Name Type
data T
Returns

Promise<void> | void


Monomitter

Ƭ Monomitter<T>: Object

Type parameters

Name
T

Type declaration

Name Type
clear () => void
publish (data: T) => Promise<void>
subscribe (cb: Callback<T>) => { unsubscribe: () => void }

Subscription

Ƭ Subscription<T>: (data: T) => Promise<void> | void

Type parameters

Name
T

Type declaration

▸ (data): Promise<void> | void

Parameters
Name Type
data T
Returns

Promise<void> | void


Unsubscribe

Ƭ Unsubscribe: () => void

Type declaration

▸ (): void

Returns

void

Functions

monomitter

monomitter<T>(): Monomitter<T>

Constructs a new event emitter, whose purpose is to emit values of the given type.

Type parameters

Name
T

Returns

Monomitter<T>

Readme

Keywords

none

Package Sidebar

Install

npm i @projectsophon/events

Weekly Downloads

0

Version

0.1.3

License

MIT

Unpacked Size

14.1 kB

Total Files

15

Last publish

Collaborators

  • phated
  • sophonbot