javascript - NodeJS when to use promises? -


this might little opinion based, important question.

should use promises async operations? if have api, likely, full stack of functions in there should use promises. if make business logic functions, should return promise. wonder if good, make return promise. mean, i'm calling functions inside while loop, each of them returns promise (the functions chained). slower use promises inside function? idea in stack combine promises , regular return values? need learn this, please don't close

if function (sometimes) asynchronous, needs return promise.
if function never asynchronous, there's no reason return promise, , should avoid it. keep simple , synchronous.


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -