Giter VIP home page Giter VIP logo

Comments (7)

0x-r4bbit avatar 0x-r4bbit commented on May 18, 2024

I think this is a feature which is definitely needed. It's also not hard to implement, but currently, listeners are just get pushed to a callbacks array and then get fired at a certain point. Now.. when taking a look at this construct... wouldn't it be cooler to use $rootScope.$broadcast() for the whole event handling? @ajoslin, what do you say?

from angular-promise-tracker.

ajoslin avatar ajoslin commented on May 18, 2024

We could use $rootScope.$broadcast.. But it seems bad to make the whole scope hierarchy be traversed for events every time any promise tracked does anything (which could potentially be many times per minute). Also the syntax is bad (look below).

...and for the callbacks, how about this (if we went with the current syntax):

myTracker.on('start', function(startArgument, promiseId) {
}).on('done', function(doneArg, promiseId) {
});

If we went with scope events, it would be:

$scope.$on('promiseTracker.start', function($event, promiseTracker, promiseId, startArg) {
});

That's too ugly IMO.

I'll be using AngularJS's nextUid function so I will never run out of ids.

from angular-promise-tracker.

jbthoma avatar jbthoma commented on May 18, 2024

Yep, perfect! That's exactly what I had in mind!

Didn't even know about their nextUid function, so thanks for that as well!

from angular-promise-tracker.

ajoslin avatar ajoslin commented on May 18, 2024

Done in 94a62dc :-)

Check the commit notes for an example.

from angular-promise-tracker.

0x-r4bbit avatar 0x-r4bbit commented on May 18, 2024

@ajoslin Great job! Just for the records: You aren't able to use angular's nextUid function (without defining it in your provider)?

from angular-promise-tracker.

ajoslin avatar ajoslin commented on May 18, 2024

Angular's isn't exposed unfortunately - it's private.

from angular-promise-tracker.

0x-r4bbit avatar 0x-r4bbit commented on May 18, 2024

Hmpf. Okay.

from angular-promise-tracker.

Related Issues (20)

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.