All blog articles by Pradeep Kodical
Pradeep Kodical

There are often cross cutting concerns in your app, such as logging, security checkpoints and or maybe business validations.

This is a very simple approach of implementing method interceptors in pure javascript.

The crux: This decorates all the methods for the given object with before and after interceptions.

intercept: function(o) {
 for (let p in o) {
 if (typeof o[p] === 'function') {
 let c = o[p];
 o[p] = function() {

Read complete blog post