@servie/events

WebJar for @servie/events

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

servie__events
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

@servie/events
WebJar for @servie/events
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/serviejs/events

Download servie__events

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/servie__events/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>servie__events</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/servie__events/
implementation 'org.webjars.npm:servie__events:1.0.0'
// https://jarcasting.com/artifacts/org.webjars.npm/servie__events/
implementation ("org.webjars.npm:servie__events:1.0.0")
'org.webjars.npm:servie__events:jar:1.0.0'
<dependency org="org.webjars.npm" name="servie__events" rev="1.0.0">
  <artifact name="servie__events" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='servie__events', version='1.0.0')
)
libraryDependencies += "org.webjars.npm" % "servie__events" % "1.0.0"
[org.webjars.npm/servie__events "1.0.0"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Events

NPM version NPM downloads Build status Test coverage Bundle size

Tiny type-safe event emitter.

Installation

npm install @servie/events --save

Usage

import { Emitter, once } from "@servie/events";

// Define an events interface using keys & argument tuples.
interface Events {
  test: [boolean];
  other: [string];
}

// Initialize an `Emitter` using your `Events` interface.
const events = new Emitter<Events>();

// Add or remove listeners.
const listener = (...args) => console.log(args);
events.on("test", listener);
events.off("test", listener);

// Emit an event.
events.emit("test", true);

// Listen to _all_ events, e.g. debugging.
const eachListener = ({ type, args }) => console.log(type, args);
events.each(eachListener);
events.none(eachListener);

// "Once" utility.
const onceListener = (...args) => console.log(args);
once(events, "test", onceListener);

TypeScript

This project is written using TypeScript and publishes the definitions directly to NPM.

License

MIT

org.webjars.npm

ServieJS

Versions

Version
1.0.0