pp-events

1.3.0 • Public • Published

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);

Package Sidebar

Install

npm i pp-events

Weekly Downloads

0

Version

1.3.0

License

MIT

Unpacked Size

12.8 kB

Total Files

12

Last publish

Collaborators

  • carlos-sweb