Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

ES6 promises not working #43

Open
bouncehead13 opened this issue Jun 19, 2017 · 6 comments
Open

ES6 promises not working #43

bouncehead13 opened this issue Jun 19, 2017 · 6 comments

Comments

@bouncehead13
Copy link

I'm currently using ES6 with my Angular 1.5.X code. The promise button library is failing to resolve the promises because of this code block.

mVal.finally(function() {
    promiseDone = true;
    handleLoadingFinished(btnEl);
});

mVal.finally is not a function with native ES6 promises. I noticed in your angular 2 version, you check for finally and then have a fallback.

if (promise.finally) {
    promise.finally(resolveLoadingState);
} else {
    promise
        .then(resolveLoadingState)
        .catch(resolveLoadingState);
}

Is it possible to have this approach included into this repo as well.

@johannesjo
Copy link
Owner

johannesjo commented Jun 19, 2017

Yes definitely! Thanks for reporting and digging into this! Would you like to create a PR for this?

@bouncehead13
Copy link
Author

bouncehead13 commented Jun 20, 2017

PR created for you to review #44

Update: Noticed I hurt the code coverage. Not being as familiar with your tests, do you any free time to improve that for me?

@johannesjo
Copy link
Owner

Thank you very much. I will do that!

@bouncehead13
Copy link
Author

Awesome! I took some time to learn the tests before creating the PR, thought I almost had it, but hit a road block trying to create a native Promise in replace of $q.defer().

Definitely available to help if need be.

@johannesjo
Copy link
Owner

johannesjo commented Jun 20, 2017

I wonder how do you make es 6 promises work for you with angular1? I might have hit the same problem as you did.

I added unit tests for them in these two commits:
5f8e561
af61d1d

But I'm unable to get the unit tests to react to the promise being resolved no matter how many scope.$apply() I'm adding.

@bouncehead13
Copy link
Author

  1. I just pulled the latest released code into my app and it's working great!
  2. For the unit tests, the second commit listed, did that not work? Reading the code, it looks right.

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

No branches or pull requests

2 participants