I have the following code that is trying to determine whether or not to execute an asynchronous call depending on a conditional statement. If the condition is not met, the call is not executed. Regardless of whether a call was executed, I want to perform some final action.
var promise;
if (!hasItemInCache)
{
promise = getItemAsychronously();
}
else
{
promise = getPromiseThatResolvesImmediately();
}
promise.then(() => { /* do some final action here */ });
Is there something in Angular that does the function of getPromiseThatResolvesImmediately()? Or do I need to implement it myself and make it a constant in my app?
Aucun commentaire:
Enregistrer un commentaire