Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about minDuration and delay #49

Closed
jtammen opened this issue Oct 27, 2014 · 4 comments
Closed

Question about minDuration and delay #49

jtammen opened this issue Oct 27, 2014 · 4 comments

Comments

@jtammen
Copy link

jtammen commented Oct 27, 2014

Hi,

I am not quite sure if I properly understood the usage of minDuration and delay.

My configuration (cgBusyDefaults):

{
  minDuration : 700,
  delay : 300
}

What I would like to achieve: only show the busy indicator if the promise takes longer than 300ms to resolve, and then show it at least for 700ms. But in my application, the busy indicator is always shown after the given delay, even if the tracked promise resolves much faster than the delay. Even if I change delay to some really high value like 2 seconds, the busy indicator is just shown after this amount of time...

Version used: angular-busy 4.1.1 and AngularJS 1.2.16.

Thanks for any hints!

@jtammen
Copy link
Author

jtammen commented Nov 7, 2014

@cgross Any idea what I might be doing wrong here?

@jtammen
Copy link
Author

jtammen commented Nov 16, 2014

@cgross I did not have the time yet to fully dig into the source code, but looking at this line, I think this might be the reason for the behavior I am seeing. If I understand it correctly, the promise that resets the durationPromise to null will be be fulfilled 'too late' because delay and min duration are figured up.

@quocnguyen
Copy link

I think you was doing just fine. It was a bug.

My version of tracker.active

tracker.active = function(){
    if (tracker.delayPromise){
        return false;
    }

    if (tracker.delayJustFinished && tracker.promises.length === 0) {
        return false;
    }

    if (tracker.durationPromise) {
        addPromiseLikeThing(tracker.durationPromise);
        return true;
    }

    return tracker.promises.length > 0;
};

@cgross cgross closed this as completed in f2e3261 Apr 12, 2015
@jtammen
Copy link
Author

jtammen commented Apr 13, 2015

👍 Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants