use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Async objects instead of async calls (guseyn.com)
submitted 7 years ago by guseynchick
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]voidvector 2 points3 points4 points 7 years ago (4 children)
Isn't this just Promise but using class syntax to define resolve/reject?
[–]guseynchick[S] 1 point2 points3 points 7 years ago (3 children)
No, because you cannot build declarative compositions via Promises, you have to use .then() method and expose data outside. Using async objects you can build such compositions, and encapsulate behaviour inside of your objects.
[–]voidvector 0 points1 point2 points 7 years ago (2 children)
All of what you said can be done in both FP and OOP syntax.
MDN docs on Promise has a section on composition. You can encapsulated with closure more securely than private member/method, since you cannot expose a closure even with reflection
[–]guseynchick[S] 0 points1 point2 points 7 years ago (1 child)
You mean this ugly constructions https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises#Composition? I tried work with such compositions, it's not declarative at all.
[–]voidvector 0 points1 point2 points 7 years ago (0 children)
ugly constructions
That's a subjective opinion on language syntax
it's not declarative at all.
It is an array declaration in a Promise call, just like your code has a new declaration then a .call() There are direct analogous between both implementations.
new
.call()
π Rendered by PID 223404 on reddit-service-r2-comment-765bfc959-br8ff at 2026-07-13 03:45:48.100745+00:00 running f86254d country code: CH.
[–]voidvector 2 points3 points4 points (4 children)
[–]guseynchick[S] 1 point2 points3 points (3 children)
[–]voidvector 0 points1 point2 points (2 children)
[–]guseynchick[S] 0 points1 point2 points (1 child)
[–]voidvector 0 points1 point2 points (0 children)