DCL

An elegant OOP with mixins + AOP for JavaScript.

dcl.before()

This is a convenience decorator to define a before advice based on dcl.advise().

Description

This is a shortcut function to define one before advice. Logically it is defined as:

dcl.before()
1
2
3
4
5
dcl.before = function(advice){
  return dcl.advise({
    before: advice
  });
};

It means that instead of:

Long
1
2
3
method: dcl.advise({
  before: advice
})

It is possible to write a shorter version:

Short
1
method: dcl.before(advice)

Advice function

This type of advice is a regular function. It is called with the same context and the same arguments as an advised method. Its return value is ignored.

It is not recommended to modify parameters inside before advice. Use around advice for that.

Fork me on GitHub