Make fetch() zone-aware without triggering extra requests or uncatchable errors.#622
Make fetch() zone-aware without triggering extra requests or uncatchable errors.#622mhevery merged 9 commits intoangular:masterfrom
Conversation
…ensuring a ZoneAwarePromise is returned. Use it on fetch().
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
1 similar comment
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
CLA signed. |
|
CLAs look good, thanks! |
1 similar comment
|
CLAs look good, thanks! |
|
Addresses #446 |
|
@MichaelBuerge , please read DEVELOPER.md, before commit part, so you can check your commit. Currently it seems your build failed with tslint part. |
|
@JiaLiPassion Apologies for missing the linter. Everything should be fine now ( |
|
@MichaelBuerge , you are welcome, could you check my review comment? especially whether the first promise is patched or not one. |
|
@JiaLiPassion I can't find your review comment. As of now, the pull request page still says "no reviews". (Am I looking in the wrong place?) However, guessing from your comment here, your question seems to be whether the first time the patched fetch() function is called its result promise is properly patched. |
| const symbolThenPatched = __symbol__('thenPatched'); | ||
|
|
||
| function patchThen(Ctor) { | ||
| let proto = Ctor.prototype; |
There was a problem hiding this comment.
I think we should use const here for proto and originalThen
| proto[symbolThen] = originalThen; | ||
|
|
||
| Ctor.prototype.then = function(onResolve, onReject) { | ||
| let wrapped = new ZoneAwarePromise( |
|
@MichaelBuerge, sorry I forget to push submit review button...
yeah, you are right! thank you for explaining this, I didn't realize that. |
|
My pleasure! |
|
Also addresses #476 |
Previous implementation called fetch() during setup in order to obtain a result promise from it so its constructor could be patched to make it zone-aware.
This had two problems:
This change replaces fetch() with a wrapper function that lazily ensures the result returned by fetch() is zone-aware.