docs: update zone-bluebird patch document for angular (#34536)
PR Close #34536
This commit is contained in:
parent
9601b5d18a
commit
3c30474417
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
Zone.js patched most standard APIs such as DOM event listeners, XMLHttpRequest in Browser, EventEmitter and fs API in Node.js so they can be in zone.
|
Zone.js patched most standard APIs such as DOM event listeners, XMLHttpRequest in Browser, EventEmitter and fs API in Node.js so they can be in zone.
|
||||||
|
|
||||||
But there are still a lot of non standard APIs that are not patched by default, such as MediaQuery, Notification,
|
But there are still a lot of non-standard APIs that are not patched by default, such as MediaQuery, Notification, WebAudio and so on. This page provides updates on the current state of zone support for Angular APIs.
|
||||||
WebAudio and so on. We are adding support to those APIs, and our progress is updated here.
|
|
||||||
|
|
||||||
## Currently supported non standard Web APIs
|
## Currently supported non-standard Web APIs
|
||||||
|
|
||||||
* MediaQuery
|
* MediaQuery
|
||||||
* Notification
|
* Notification
|
||||||
|
@ -26,7 +25,7 @@ Usage:
|
||||||
|
|
||||||
## Currently supported non standard common APIs
|
## Currently supported non standard common APIs
|
||||||
|
|
||||||
* bluebird promise
|
* [Bluebird](http://bluebirdjs.com/docs/getting-started.html] Promise
|
||||||
|
|
||||||
Browser Usage:
|
Browser Usage:
|
||||||
|
|
||||||
|
@ -39,7 +38,29 @@ Browser Usage:
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
After those steps, window.Promise will become a ZoneAware Bluebird Promise.
|
After those steps, window.Promise becomes Bluebird Promise and will also be zone awareness.
|
||||||
|
|
||||||
|
Angular Usage:
|
||||||
|
|
||||||
|
in polyfills.ts, import the `zone-bluebird` package.
|
||||||
|
|
||||||
|
```
|
||||||
|
import 'zone.js/dist/zone'; // Included with Angular CLI.
|
||||||
|
import 'zone.js/dist/zone-bluebird';
|
||||||
|
```
|
||||||
|
|
||||||
|
in main.ts, patch bluebird.
|
||||||
|
|
||||||
|
```
|
||||||
|
platformBrowserDynamic()
|
||||||
|
.bootstrapModule(AppModule)
|
||||||
|
.then(_ => {
|
||||||
|
import('bluebird').then(Bluebird => {const Zone = (window as any)['Zone']; Zone[Zone['__symbol__']('bluebird')](Bluebird.default);});
|
||||||
|
})
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
```
|
||||||
|
|
||||||
|
After this step, the `window.Promise` will be the Bluebird `Promise`, and the callback of `Bluebird.then` will be executed in the Angular zone.
|
||||||
|
|
||||||
Node Sample Usage:
|
Node Sample Usage:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue