1.0.0 • Published 8 years ago
sarina.event v1.0.0
Sarina.Event
This plugin has implemented NodeJs Event for sarina. Plugin created by JavadParvaresh.
Table of contents
Quick start
Several quick start options are available:
- Clone the repo:
git clone https://github.com/javadparvaresh/Sarina-event.git
- Install with npm:
npm install sarina.event
Bugs and feature requests
Have a bug or a feature request? please open a new issue.
The Basics
var sarina=require("sarina");
var sarinaevent=require("sarinaevent");
// create a sarina app by passing configuration
var app=sarina.create({});
// create subscriber for an event
app.exec("subscriber",["event"],function($event){
return {
run:function(){
return new Promise(function(resolve,reject){
$event.on('hi',function(name){ // receiver event and handle functionality
console.log("hi name");
})
})
}
}
});
// create a publisher for hi event
app.exec("publisher",["event"],function($event){
return {
run:function(){
return new Promise(function(resolve,reject){
$event.emit('hi','javad'); // we publish an event
})
}
}
});
// add to modules
app.module(sarinaevent);
1.0.0
8 years ago