new SCEventWrapper()

Description

Supports automatically before - after triggering events for user-defined methods to support AOP similar functionality.

End-user classes like SCModel and ServiceController augments this class so they automatically trigger events for their methods.

These events will be prefixed with before: or after:, then the provided name and last the method name.
Also, listeners will receive method parameters and return value (in case of after:).

For example, we can hook to the time when an LiveOrder is submitted so we can customize its behavior like this:

Application.on('before:LiveOrder:save', function()
			{
			     ... do something before submitting a live order ...
			})
			

Members


name :string

Description

The name of this model. Is mandatory that al SCEventWrappers to have a name.

Methods


<static> extend( definition ) → {Class.<SCEventWrapper>}

Description

Create a new class with provided name and methods that will automatically trigger after and before events when
methods are called to provide AOP-similar functionality.

Parameters
Name Type Description
definition Object

The definition for the new model that contain a name and the model methods to wrap.
The name is mandatory.

Returns