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
npm i pp-events --save
var ppEvents = require("pp-events")
var Event = ppEvents() // Or new ppEvents()
// 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();
});
})
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);
Event.on("eventName",myFunction);
Event.emit("eventName",{
mydata:"myvalue",
otherData:"otherValue"
});
Event.checkOn("eventName");
Event.removeListener("eventName",myFunction);