Git Product home page Git Product logo

Comments (9)

mgechev avatar mgechev commented on August 18, 2024

This sounds like a very useful idea.
I'll consider its implementation.

from angular-aop.

christianacca avatar christianacca commented on August 18, 2024

That would be great

from angular-aop.

mgechev avatar mgechev commented on August 18, 2024

I implemented it. I'll be happy if you verify it works.

Now the advices for the before, after and around point-cuts should be able to modify the base function arguments and result.
You will be able to modify the function arguments by changing the args array in the advice:

DemoApp.factory('Logger', function () {
  return function (args) {
    if (args.exception) {
      console.log('%cException: ' + args.exception.message + '. ' + args.method + ' called before proper authorization.',
      'color: red; text-weight: bold; font-size: 1.2em;');
    }

    /* Arguments change */
    args.args = ['New argument', 'One more new argument'];
    /* end of the arguments change */

    var throwData = (args.exception) ? ' and threw: ' + args.exception.message : '';
    console.log('Method: ' + args.method + ', Pointcut: ' + args.when + ', with arguments: ' +
          angular.toJson(args.args) + throwData + ' and resolve data: ' +
          angular.toJson(args.resolveArgs) + ', reject data: ' + angular.toJson(args.rejectArgs));
  };
});

from angular-aop.

christianacca avatar christianacca commented on August 18, 2024

Hey Minko, sorry I haven't got back to you sooner. Thanks for implementing this.

This will be very handy indeed. The thing is I still have reservations about the nesting of aspects when you need to apply multiple before, after, etc aspects to the same function(s). It makes debugging your own code very cumbersome - so much so that I think other developers would hate me for introducing AOP!

I was reading Javascript Allonge (very good functional programming book), and came across the same complaint and a solution for the problem proposed by the author in the following implementation of his AOP javascript library: raganwald - YouAreDaChef

Christian

from angular-aop.

mgechev avatar mgechev commented on August 18, 2024

I will include improving this framework in my Christmas TODO list.

If you can provide me some use cases, different from the most common ones - logging, authorization, in which you've applied AOP with AngularJS you'll help me a lot!

from angular-aop.

christianacca avatar christianacca commented on August 18, 2024

Hi Minko,

Sounds like you're going to have some fun! For me I think the idea of AOP
is great, I just know it can obscure the debugging experience - something
I've said a few times I know ;-)

Anyway here are a few use cases I've either implemented or thought might be
a good fit for AOP:

  1. Caching for data services
  2. Applying exception handling policy at boundary points / between layers
  3. Retry logic, circuit breakers, etc
  4. Applying security policies
  5. Instrumentation to gather performance statistics

Christian

On Sun, Nov 17, 2013 at 10:04 AM, Minko Gechev [email protected]:

I will include improving this framework in my Christmas TODO list.

If you can provide me some use cases, different from the most common ones

  • logging, authorization, in which you've applied AOP with AngularJS you'll
    be very helpful!


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-28645761
.

from angular-aop.

mgechev avatar mgechev commented on August 18, 2024

Would you mind citing you inside the readme file?

I'm writing a research paper for AOP. I plan to include Angular AOP as JavaScript example so I needed some concrete examples to provide strong arguments for its usage.

Thank you for your response! I haven't considered some of ones you suggested.

from angular-aop.

christianacca avatar christianacca commented on August 18, 2024

Of course no problem Minko. Good luck, and looking forward to seeing the
outcome.

C

On Mon, Nov 18, 2013 at 7:37 AM, Minko Gechev [email protected]:

Would you mind citing you inside the readme file?

I'm writing a research paper for AOP. I plan to include Angular AOP as
JavaScript example so I needed some concrete examples to provide strong
arguments for its usage.

Thank you for your response! I haven't considered some of ones you
suggested.


Reply to this email directly or view it on GitHubhttps://github.com//issues/6#issuecomment-28679727
.

from angular-aop.

mgechev avatar mgechev commented on August 18, 2024

Closing this on, it looks like #5

from angular-aop.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.