-
Notifications
You must be signed in to change notification settings - Fork 407
zones and bluebird in node? #793
Comments
@mike-kaufman, you can still use the instructions described in https://github.com/angular/zone.js/blob/master/NON-STANDARD-APIS.md#user-content-currently-supported-non-standard-common-apis. I have did some basic test about the promise API which exposed by |
Thanks @JiaLiPassion - I'm not clear on where |
@mike-kaufman, the |
@JiaLiPassion - Thanks for the quick responses. A couple of issues here:
Please let me know if I'm missing something. I'm happy to submit a patch so that the "magic docs" becomes a "magic method", but would need guidance on where to best expose. |
@mike-kaufman , I will update document later. require('zone.js');
const Bluebird = require('bluebird');
require('./node_modules/zone.js/dist/zone-bluebird');
Zone[Zone['__symbol__']('bluebird')](Bluebird);
Zone.current.fork({
name: 'bluebird'
}).run(() => {
Bluebird.resolve(1).then(r => {
console.log('result ', r, 'Zone', Zone.current.name);
});
}); |
So, to be precise, this:
Doesn't work for me. It fails to find 'zone-bluebird'. (Possibly because I have multiple modules in play in here? Irrespective, above is not idiomatic, and I don't think it will work given that npm can de-dupe packages such that zone.js is not necessarily in my modules' node_modules directory. What I want is something like this: const zones = require('zone.js')
zones.enableBluebird(); Where export function enableBluebird() {
const Bluebird = require('bluebird');
require('./zone-bluebird');
Zone[Zone['__symbol__']('bluebird')](Bluebird);
} I'm happy to submit a PR, but I don't know your build pipeline and would need some guidance as to where this code should live. |
@mike-kaufman , you can check the
I am not sure that so the current idea is , if you want to patch |
Thanks @JiaLiPassion.
The issue isn't that zone-bluebird doesn't exist. The issue is "where do I find it?".
Not really... I don't think the dependencies change at all over what you're currently providing. Of course, if someone calls |
@mike-kaufman , I understand your point.
Basically, in my understanding, the API for bluebird in zone has 3 concerns.
currently the reason we have such API is bluebird is not a global object, maybe remove this API and change the usage to
is better.
how application code access the patched And Bluebird support |
I think this addresses your concerns: export function patchBluebird(bluebird) {
require('./zone-bluebird');
Zone[Zone['__symbol__']('bluebird')](bluebird);
return bluebird;
} Then caller can do this: const zones = require('zone.js');
const bluebird = zones.patchBluebird(require('bluebird')); The salient thing here is that reaching into the zone.js installed location is problematic & not idiomatic, so there really should be a work-around |
@mike-kaufman , yeah, pass Bluebird as parameter is ok, but it still require that zone load Bluebird patch function definition by default. for example, when you use
And in zone.js case, you can do like this after nodejs support
|
So, for this,
How does this work exactly? Don't I need to to know the full path to where zone.js is installed? |
@mike-kaufman , no, you don't need to know where |
How does this work on down-level runtimes that don't support es6? |
@mike-kaufman , I think you may need to use babel polyfill to do that. Or you can use typescript. |
What's the recommendation for getting Zones to work w/ bluebird in node? There are some instructions here, but they're out of date, or I'm missing something. :)
Thanks much!
Mike
The text was updated successfully, but these errors were encountered: