forked from pencilblue/pencilblue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pencilblue#1135 from pencilblue/feature/reqhandler…
…hooks Request Handler Hook - On Theme Route Retrieved
- Loading branch information
Showing
6 changed files
with
297 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
Copyright (C) 2016 PencilBlue, LLC | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
'use strict'; | ||
|
||
//dependencies | ||
var AsyncEventEmitterLib = require('async-eventemitter'); | ||
|
||
module.exports = function(pb) { | ||
|
||
/** | ||
* @static | ||
* @class AsyncEventEmitter | ||
*/ | ||
function AsyncEventEmitter(){} | ||
|
||
/** | ||
* @static | ||
* @method extend | ||
* @param {function} prototype | ||
*/ | ||
AsyncEventEmitter.extend = function(prototype) { | ||
var events = new AsyncEventEmitterLib(); | ||
|
||
/** | ||
* Registers a listener for the specified event. | ||
* @static | ||
* @method on | ||
* @param {String} event | ||
* @param {Function} listener | ||
* @return {*} | ||
*/ | ||
prototype.on = function(event, listener) { | ||
return events.on(event, listener); | ||
}; | ||
|
||
/** | ||
* Registers a listener to fire a single time for the specfied event | ||
* @static | ||
* @method once | ||
* @param {String} event | ||
* @param {Function} listener | ||
* @return {*} | ||
*/ | ||
prototype.once = function(event, listener) { | ||
return events.once(event, listener); | ||
}; | ||
|
||
/** | ||
* Removes the listener from the specified event | ||
* @static | ||
* @method removeListener | ||
* @param {String} event | ||
* @param {Function} listener | ||
* @return {*} | ||
*/ | ||
prototype.removeListener = function(event, listener) { | ||
return events.removeListener(event, listener); | ||
}; | ||
|
||
/** | ||
* Removes all listeners for the specified event | ||
* @static | ||
* @method removeAllListeners | ||
* @param {String} event | ||
* @return {*} | ||
*/ | ||
prototype.removeAllListeners = function(event) { | ||
return events.removeAllListeners(event); | ||
}; | ||
|
||
/** | ||
* Sets the maximum number of listeners for the emitter | ||
* @static | ||
* @method setMaxListeners | ||
* @param {Integer} n | ||
* @return {EventEmitter} | ||
*/ | ||
prototype.setMaxListeners = function(n) { | ||
return events.setMaxListeners(n); | ||
}; | ||
|
||
/** | ||
* Returns a list of the listeners for the specified event | ||
* @static | ||
* @method listeners | ||
* @param {String} event | ||
* @return {Array} | ||
*/ | ||
prototype.listeners = function(event) { | ||
return events.listeners(event); | ||
}; | ||
|
||
/** | ||
* | ||
* @static | ||
* @method emit | ||
* @param {String} event | ||
* @param {Object} data | ||
* @param {Function} cb (Error) | ||
*/ | ||
prototype.emit = function(event, data, cb) { | ||
var listeners = events.listeners(event); | ||
if (listeners.length === 0) { | ||
return cb(); | ||
} | ||
|
||
pb.log.silly('AsyncEventEmitter: Emitting events: [%s] to %s listeners', event, listeners.length); | ||
events.emit(event, data, cb); | ||
}; | ||
}; | ||
|
||
return AsyncEventEmitter; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.