Created
January 24, 2014 20:15
-
-
Save ktkaushik/8605397 to your computer and use it in GitHub Desktop.
filters in rendr controller
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
/** | |
* | |
*/ | |
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