5 ms·
I hope the node APIs are changed/extended to return promises eventually so I don't have to keep on using promise wrappers for all of them.
by AgentME 10y ago
I hope the node APIs are changed/extended to return promises eventually so I don't have to keep on using promise wrappers for all of them.
- BinaryIdiot 10y agoIs there a reason you always wrap them? Even if it's awkward I tend to leave most platform APIs alone and treat them as special cases if I'm doing something, say, promises or messages.
- WorldMaker 10y agoPromises are much each to compose. Promise objects can be passed around and reused. (Multiple things can wait on the result of the same promise.) Code is much easier to read with flat .then() and .catch() chains, versus sometimes the "pyramid of doom" callbacks can create. Code is much, much easier to read with Promises when you can use async/await, and getting everything wrapped to promises now makes it that much sooner you can use async/await.
- BinaryIdiot 10y agoI get the why people want to use Promises in general but when they're used to simply wrap a standard node / browser call feels dirty to me because it changes what you expect it to return (e.g. a promise instead of whatever it normal returns). I dunno I just don't like to give the impression I'm changing anything about how I'm accessing / using the standard library but I guess this is a bit subjective. > versus sometimes the "pyramid of doom" callbacks can create If you structure the code well you never run into this (callback soup is very overblown; if you find yourself in that position then someone screwed something up). But I get promises and async / await are nice :)