angular / zone.js

Implements Zones for JavaScript
https://github.com/angular/angular/tree/master/packages/zone.js/
MIT License
3.25k stars 407 forks source link

Provide example for using in plain JavaScript Node.js app #1208

Closed matthewadams closed 5 years ago

matthewadams commented 5 years ago

This could be an RTFM, but it'd be jim-dandy if you could provide a working example of how to properly use zone.js in a headless, plain JavaScript Node.js app that I'd run in a terminal with node index.js.

https://github.com/angular/zone.js/blob/HEAD/SAMPLE.md contains what appears to be only browser-based examples.

JiaLiPassion commented 5 years ago

@matthewadams, sure, I will add it! Thanks!

matthewadams commented 5 years ago

@JiaLiPassion I'm dead in the water right now. If you could throw something together quickly so that I could get going, I'd really appreciate it! :)

Currently, I'm getting undefined for Zone.current.

JiaLiPassion commented 5 years ago

@matthewadams, here is a very basic sample, https://github.com/JiaLiPassion/zone-node

matthewadams commented 5 years ago

Ah, ok. By doing require('zone.js/dist/zone-node'), you get a global variable Zone. That's the difference.

Perhaps it's worth updating the documentation to say that? Thanks!

I'll try it out, and reopen this issue if I'm having trouble.

JiaLiPassion commented 5 years ago

@matthewadams, sure, I will make documentation more clearly, thanks!