1.0.1 • Published 6 years ago

eventsmiddelware v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
6 years ago

//command to install this package//

npm i eventsmiddelware;

//it returns the EventMiddelware class or constructor with extended events methods and features with new add method function:addAllListener To create the instance of the Eventmiddelware class or constructor you can use the addAllListener method .it is similar to addListener or on functions in events module// //it simply hold number of listener functions to one event instead of using on function for multiple time, it simply avoid redundent//

ex:- var e= require("events"); e=new e(); e.on("go",function(){console.log("where are you going to buddy?");}); e.on("go",function(){console.log("i am going to the bazar.i need your help,can you join with me");}); e.emit("go");

(or)// the newer addAllListener makes yor repeated events and their listeners in same line //

var e= require("events"); e=new e(); e.addAllListener("go",function(){console.log("where are you going to buddy?"),function(){console.log("i am going to the bazar.i need your help,can you join with me");}); e.emit("go");

simple example:-

var EMC=require('eventsmiddelware'); var i1=new EMC(); i1.addAllListener("fun",function funnyIncident(){console.log("this is a funny incident");},function funMaker(){console.log("you makes me fun");},function funnyBoy(){console.log("you are a funny boy");}); i1.emit("fun");

syntax: addAllListener(eventName, function in serious form using comma notations); ex:-

addAllListener("hello",function(){console.log("hello buddy");},function hiFrnd(){console.log("hi frnds");},...);

// where the first parameter is the string and the next sequence of parameters are functions;//

full example:- var EMC=require('eventsmiddelware'); var i1=new EMC(); i1.addAllListener("fun",function funnyIncident(){console.log("this is a funny incident");},function funMaker(){console.log("you makes me fun");},function funnyBoy(){console.log("you are a funny boy");}); i1.emit("fun");

//function:addAllListener need atlest 2 parameters, (i.e) eventName:(type = string) and eventListener:(type = string) // // must need 2 params else throw TypeError//

ex:- var EMC=require('eventsmiddelware'); var i1=new EMC(); i1.addAllListener("script",function(){console.log("javascript makes my life easier");}); 11.emit("script");

.....thank you.....

contact : hemanathancv.ml developer : Hemanathan;

1.0.1

6 years ago

1.0.0

6 years ago