Socket
Socket
Sign inDemoInstall

@okikio/emitter

Package Overview
Dependencies
1
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @okikio/emitter

A small Event Emitter written in typescript with performance and ease of use in mind.


Version published
Weekly downloads
261
decreased by-1.14%
Maintainers
1
Install size
88.6 kB
Created
Weekly downloads
 

Readme

Source

@okikio/emitter

npm npm bundle size GitHub

A small Event Emitter written in typescript with performance and ease of use in mind, it weighs ~834 B (minified and gzipped).

Table of Contents

Installation

You can install @okikio/emitter from npm via npm i @okikio/emitter, pnpm i @okikio/emitter or yarn add @okikio/emitter.

You can use @okikio/emitter on the web via:

Once installed it can be used like this:

// There is,
//      .cjs - Common JS Module
//      .mjs - Modern ES Module
//      .js - IIFE
import { EventEmitter } from "@okikio/emitter";
import { EventEmitter } from "https://unpkg.com/@okikio/emitter";
import { EventEmitter } from "https://cdn.jsdelivr.net/npm/@okikio/emitter";
// Or
import { EventEmitter } from "https://cdn.skypack.dev/@okikio/emitter";

// Via script tag
<script src="https://unpkg.com/@okikio/emitter/lib/api.js"></script>
// Do note, on the web you need to do this, if you installed it via the script tag:
const { EventEmitter } = window.emitter;

Getting started

The EventEmitter class is what runs the show for the @okikio/emitter library. To use it properly you need to create a new instance of EventEmitter, the instance of EventEmitter is what allows for event emitting, and listening.

EventEmitter allows for an easy way to manage events. It inherits properties/methods from @okikio/manager.

// You need to first initialize a new Event Emitter
const emitter = new EventEmitter();

// Then listen for an event
emitter.on("new-event", () => {
    console.log("A new event occured");
});

// Then emit or fire the event
setTimeout(() => {
    // Eg. after 3 seconds fire the `new-event` listener
    emitter.emit("new-event"); //= A new event occured
}, 3000);

Read through the API guide to learn more.

Browser & Node Support

ChromeEdgeFirefoxIE
> 38> 12> 13> 11

Learn about polyfilling, bundling, and more in the platform support guide.

Contributing

If there is something I missed, a mistake, or a feature you would like added please create an issue or a pull request on the beta branch and I'll try to get to it.

You can try out @okikio/emitter using Gitpod:

Open In Gitpod

Read through the contributing documentation for detailed guides.

Keywords

FAQs

Last updated on 30 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc