Page MenuHomeSealhub

service.js
No OneTemporary

service.js

var Promise = require("bluebird");
var Service = function(longid, mode){
this.longid = longid;
this.event_handlers = {};
}
Service.prototype = new function(){
this.on = function(event_name, callback){
if(!this.event_handlers[event_name]){
this.event_handlers[event_name] = callback;
}
}
this.fire_action = function(event_name, payload){
var that = this;
return new Promise(function(resolve, reject){
if(!that.event_handlers[event_name]){
throw new Error("event ", event_name, "does not have a handler attached");
}else{
that.event_handlers[event_name](payload, function(){
resolve();
});
}
})
}
this.prepare = function(){
return true;
}
this.start = function(){
return true;
}
}
Service.is_a_constructor = false;
module.exports = Service;

File Metadata

Mime Type
text/plain
Expires
Tue, May 27, 23:48 (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
712556
Default Alt Text
service.js (803 B)

Event Timeline