All blog articles by Pradeep Kodical
9b3ae088559294e0d87be3ce534b4485
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() {
 MIFactory.beforeExecution(o,...

Read complete blog post