pp-events

1.2.5 • 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

4

Version

1.2.5

License

MIT

Unpacked Size

7.16 kB

Total Files

5

Last publish

Collaborators

  • carlos-sweb