New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

oseventlistener

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oseventlistener

A simple modern a strong typed javascript library to subscribe, manage and dispatch events

latest
Source
npmnpm
Version
1.0.6
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status npm version Coverage Status Donations via PayPal

OSEventListener

A simple Typescript/VanillaJS Event Listener

Why choose OS Event Listener?

  • It is modern, code written in Typescript with ES2020 target and ES Modules.
  • It is simple to use.
  • It is cross compatible, it works in any browser with at least ES2015 support, NodeJs and more.
  • It is modular, it supports AMD, UMD, CommonJS, SystemJs module loading systems.
  • Works very well in a browser without any deps or tools, because it provides an iife browser bundle that exposes the library on window ready to be used.
  • It is strong typed, thanks to Typescript it provides type definitions, there is no use of "any" type.
  • It is advanced, the behavior can be changed with custom options covering most of use cases.

How to load it

You can check samples here: https://github.com/OrbintSoft/OSEventListener/blob/master/sample

If you checkout the git project you can run npm run server, to start a simple server and test the varius module loading.

Below the supported module loading systems

AMD: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/amd.html

UMD: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/umd.html

System.JS: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/system.html

Browser / IIFE Bundle: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/bundle.html

ES6: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/es.html

NodeJs / CommonJS: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/node_sample.cjs

NodeJs / ES module: https://github.com/OrbintSoft/OSEventListener/blob/master/sample/node_sample.mjs

How to use:

Create an Event

const event = new EventListener('name');

Subscribe to an event

const fn = (sender, data) => {
	console.log(data);
};
event.subscribe(fn);

Subscribe with key

event.subscribeWithKey((sender, data) => {
	console.log(data);
}, 'logdata');

Unsubscribe to an event

event.unsubscribe(fn);

Unsubscribe with key

event.unsubscribeWithKey('logdata');

Dispatch an event

event.dispatch(this, 'my data');

Documentation

For detailed doc, check here:

Keywords

event

FAQs

Package last updated on 14 Aug 2022

Did you know?

Socket

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