Skip to content

Instantly share code, notes, and snippets.

@ktkaushik
Created January 24, 2014 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktkaushik/8605397 to your computer and use it in GitHub Desktop.
Save ktkaushik/8605397 to your computer and use it in GitHub Desktop.
filters in rendr controller
/**
*
*/
var _ = require('underscore')
, async = require('async');
function originalFilter(actionHandler) {
return function () {
actionHandler.apply(this, arguments);
};
}
function asyncFilter (actionHandler) {
return function() {
var args = arguments;
async.series([
function(cb){
console.log("in the first **** **** **** **** ");
cb(null, 'one');
},
function(cb){
console.log("in the second **** **** **** **** ");
cb(null, args);
}
]);
actionHandler.apply(this, arguments);
};
}
function wrapperFilter () {
var args = arguments;
async.series([
function(cb){
console.log("in the first **** **** **** **** ");
cb(null, 'one');
},
function(cb){
console.log("in the second **** **** **** **** ");
cb(null, args);
}
]);
}
function afterFilter () {
console.log("YOu are in after filter ........");
}
module.exports = {
/**
*
*/
index: function(params, callback) {
var index = _.wrap(callback, function(func) {
wrapperFilter();
func(null, {});
afterFilter();
});
index();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment