Skip to content

carlos-sweb/pp-events

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

In the web project include pp-events.js with:

<script src="https://cdn.jsdelivr.net/npm/pp-is@latest/pp-is.min.js" ></script>
<script src="https://cdn.jsdelivr.net/npm/pp-events@latest/pp-events.min.js" ></script>

Or

Install

npm i pp-events --save

Initialize

Nodejs

var ppEvents = require("pp-events")

var Event = ppEvents() // Or new ppEvents()

RequireJS

// in data-main script file
requirejs.config({    
    baseUrl:"node_modules/",
    paths: {
        "pp-is": "pp-is/pp-is.min",
        "pp-events":"pp-events/pp-events"
    }
});
// in your main js file
require(["config"],function(){
	require(["pp-events"],function(ppEvents){
		const Event = ppEvents(); // or new events();
	});
})

Browser Javascript

var Event = ppEvents() // Or new ppEvents()

//say hello function for execute
var sayHello = function( msg ){
	console.log(msg)
}

Event.on("sayHello",sayHello)

Event.emit("sayHello","Hi everyone !!!!!")

// remove Events if will be necesary

Event.removeListener("sayHello",sayHello);

Methods

on

Event.on("eventName",myFunction);

emit

Event.emit("eventName",{
	mydata:"myvalue",
	otherData:"otherValue"
});

checkOn

Event.checkOn("eventName");

removeListener

Event.removeListener("eventName",myFunction);

About

Simple manager events of Javascript

Resources

License

Stars

Watchers

Forks

Packages

No packages published