Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

wire aop

Brian Cavalier edited this page · 5 revisions

wire/aop

This plugin lets you apply AOP techniques like decorators, introductions (mixins), and pointcut-based advice aspects to components during the wiring process.

Options

{
    module: 'wire/debug',

    // aspects
    // Array of aspects to apply during wiring
    aspects: [
        // Can reference aspects declared later in the wire spec
        'refToAspect1',
        'refToAspect2',
        // Or pointcuts can be declared explicitly
        {
            // pointcut can be Array of Strings, RegExp, or String ref
            // name of pointcut declared later in the wire spec
            pointcut: ['aMethodNameToAdvise', 'anotherMethodNameToAdvise'],
            // Reference to advice declared later in the wire spec
            advice: 'refToAdvice'
        }
        // ... more aspects ...
    ]
}

Decorators

Decorators allow you to apply a standard decorator pattern explicitly to components in the wire spec.

Example

{
    // Add the wire/aop plugin
    plugins: [
        { module: 'wire/aop' }
    ],

    // Create a decorator
    // This should be a function that will decorate a component
    myDecorator: { module: 'my/Decorator' },

    // Create a component
    myComponent: {
        // Create an instance of my/Component
        create: 'my/Component',

        // Explicitly decorate it with myDecorator
        // myComponent will be passed as the first parameter to
        // myDecorator.  Other args specified below will be the
        // second, third, etc. parameters.
        decorate: {
            myDecorator: [/* other args to pass to decorator function */]
        }
    }

}

More coming soon

Introductions

Introductions allow you to mixin functionality to components in the wire spec.

{
    // Add the wire/aop plugin
    plugins: [
        { module: 'wire/aop' }
    ],

    // Create the mixin
    // This can be any object
    myMixin: { module: 'my/Mixin' },

    // Create a component
    myComponent: {
        // Create an instance of my/Component
        create: 'my/Component',

        // Explicitly introduce myMixin into myComponent.
        // All of myMixins properties will be added to myComponent.
        introduce: ['myMixin' /*, ... other mixins ... */]

        // Shorthand if you only have a single mixin:
        // introduce: 'myMixin'
    }
}

More coming soon

Advice

More coming soon

Pointcut-based Advice

More coming soon

Something went wrong with that request. Please try again.