Jeff-Lewis / cls-hooked

cls-hooked : CLS using AsynWrap or async_hooks instead of async-listener for node 4.7+
BSD 2-Clause "Simplified" License
758 stars 89 forks source link

Document ns.enter()/.exit() methods #44

Open puzpuzpuz opened 5 years ago

puzpuzpuz commented 5 years ago

These methods should be included into the documentation (and thus, included into public API) as there are some use cases when ns.run()/.runAndReturn()/.bind() are not an option.

Namely, ns.enter()/.exit() methods are very helpful in case of generators. See here for an example: https://github.com/puzpuzpuz/cls-rtracer/blob/master/index.js#L76

jrnail23 commented 5 years ago

Wow, @puzpuzpuz, that was the exact usecase (Koa V1 middleware) I was trying to implement. Thanks!

puzpuzpuz commented 5 years ago

@jrnail23 no problem at all. Glad that this information was helpful.