Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the difference with zonejs? #17

Open
JSteunou opened this issue Jul 27, 2018 · 3 comments
Open

What's the difference with zonejs? #17

JSteunou opened this issue Jul 27, 2018 · 3 comments
Labels

Comments

@JSteunou
Copy link

I was looking for a solution like this one and I saw several good candidates, but I did not search enough, yet, to understand the true differences between each. Until then maybe you can enlight me about the differences between express-http-context and zonejs (in a MW). Maybe it is more a question for the cls-hook author but as I saw your project I jump on the occasion :)

@skonves
Copy link
Owner

skonves commented Jul 27, 2018

This library was built on Node's native continuation APIs. Originally it used the now deprecated domain API. More recently we have switched over to the new async_hooks API. In contrast Zone.js seems to have implemented their own internal functionality for persisting context over async operations.

From another perspective, this library aspires to the Unix philosophy of "do one thing and do it well." It provides an Express middleware to access native Node APIs. As such, it remains lightweight and (hopefully) a good foundation for other more complex features and functionality.

If you are looking for a small, lightweight, foundational library, then consider this library. If you are looking for a larger "batteries included" package, consider Zone.js.

I hope this feedback was helpful. Please let me know if you have any other questions 😄

@skonves skonves changed the title [Naive question] What's the difference with zonejs? What's the difference with zonejs? Jul 27, 2018
@JSteunou
Copy link
Author

Wow very helpful indeed! Thank you for the quick response @skonves

I scratched a little more and this is what I understand now, correct me if I'm wrong. This MW approach is to use hooks to listen to changes of internal stack thread or "false thread id" (I dont know how to name it but I hope you see the picture) in order to maintain a current list of http context and return the right one when needed. So this is very specific to this need. Whereas zonejs approach is more to patch everything to make things like it seems we are in real multi-thread, like http-context but for everything, using every tricks it can (so maybe async hook also) under the hood. Is that it?

@skonves
Copy link
Owner

skonves commented Jul 27, 2018

I think that is a fair assessment 👍

As a matter of transparency, I have never used Zone.js (other than a dependency of an Angular project) so my knowledge thus far comes from reading the docs and searching through their code on GitHub :)

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

No branches or pull requests

2 participants