Skip to content

Simple events library that built to take advantage of JavaScript Proxy

Notifications You must be signed in to change notification settings

qurafi/proximitter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Simple events library that built to take advantage of JavaScript Proxy

Quick Start

// automatically add "init" handler
events.oninit = () => {
    console.log("init1");
};

// same as
events.on("init", () => {
    console.log("init2");
});


// using once
events.onceinit = () => {
    console.log("this will called once");
};

//same as
events.once("init", () => {
    console.log("this will called once");
});


// trigger event on all handlers
events.emit("init");


// remove all handlers
events.off("init");

// remove specific handler
events.off("init", callback);

API

// Similar to NodeJS. Just extra proxy handlers
Proximitter.on(eventName, callback, n=Infinity)
Proximitter.once(eventName, callback)
Proximitter.off(eventName, callback)
Proximitter.emit(eventName, ...args)

Proximitter.on"EventName" = callback
Proximitter.once"EventName" = callback

About

Simple events library that built to take advantage of JavaScript Proxy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published