
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
angular-aop
Advanced tools
If you prefer learning by doing (trial and error), come right this way.
AngularAOP allows you to apply aspect-oriented programming in your AngularJS applications.
If you notice that you have cross-cutting concerns you can isolate them in individual services and apply them as follows:
myModule.config(function ($provide, executeProvider) {
executeProvider.annotate($provide, {
ServiceToWove: [{
jointPoint: JOINT_POINT,
advice: ADVICE_NAME,
methodPattern: /Special/
argsPattern: [/arg1/, /arg2/]
}, {
jointPoint: JOINT_POINT
advice: ADVICE_NAME
}]
});
});
The joint-points supported in the current version of the framework are:
after
- the advice will be invoked after the target methodafterResolveOf
- the advice will be invoked after the promise returned by target method has been resolved and after the resolve callback attached to the promise is invokedaroundAsync
- the advice will be invoked before the target method was invoked and after the promise returned by it was resolvedaround
- the advice will be invoked before the target method was invoked and after it was invokedbeforeAsync
- the target method will be called after the promise returned by the advice was resolvedbefore
- the target method will be invoked after the adviceonRejectOf
- the advice will be invoked when the promise returned by the target method was rejectedonResolveOf
- the advice will be invoked after the promise returned by the target method was resolved but before the resolve callback attached to the promise is invokedonThrowOf
- the advice will be called if the target method throws an errorFor additional information about Aspect-Oriented Programming and AngularAOP visit the project's documentation and this blog post.
New way of annotating. Now you can annotate in your config callback:
DemoApp.config(function ($provide, executeProvider) {
executeProvider.annotate($provide, {
ArticlesCollection: {
jointPoint: 'before',
advice: 'Logger',
methodPattern: /Special/,
argsPatterns: [/arg1/, /arg2/, ..., /argn/]
}
});
});
Multiple aspects can be applied to single service through the new way of annotation:
DemoApp.config(function ($provide, executeProvider) {
executeProvider.annotate($provide, {
ArticlesCollection: [{
jointPoint: 'before',
advice: 'Logger',
}, {
//aspect 2
}, {
//aspect 3
}, ... , {
//aspect n
}]
});
});
Note: In this way you won't couple your target methods/objects with the aspect at all but your target service must be defined as provider.
Added forceObject
property to the rules. This way issues like #12 will not be reproducable since we can force the framework to wrap the target's method, insted of the target itself (in case the target is a function with "static" methods").
Issues fixed:
Added tests for:
Add JSCS and update Gruntfile.js
deep
config property, which allows adding wrappers to prototype methodsforceObject
'use strict';
at the top of the IIFEexecuteProvider
, so now the following code is valid:myModule.config(function ($provide, executeProvider) {
executeProvider.annotate($provide, {
ServiceToWove: [{
jointPoint: executeProvider.ON_THROW,
advice: ADVICE_NAME,
methodPattern: /Special/
argsPattern: [/arg1/, /arg2/]
}, {
jointPoint: executeProvider.BEFORE,
advice: ADVICE_NAME
}]
});
});
Object.setPrototypeOf
.joinpoint.proceed()
$provide.provider
might be required)This is not issue in AngularAOP but something which should be considered when using Dependency Injection.
Note that if the $injector
tries to get a service that depends on itself, either directly or indirectly you will get error "Circular dependency". To fix this, construct your dependency chain such that there are no circular dependencies. Check the following article, it can give you a basic idea how to procceed.
mgechev | david-gang | Wizek | slobo | christianacca | peernohell |
AngularAOP is distributed under the terms of the MIT license.
FAQs
Framework for aspect-oriented programming with AngularJS
The npm package angular-aop receives a total of 0 weekly downloads. As such, angular-aop popularity was classified as not popular.
We found that angular-aop demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.