There is a condition:
let needPromise = true;
And promise function:
getLayerId(): Promise<string> {
return new Promise((resolve, reject) => {
if(needPromise) {
//
}
});
}
Somewhere I need to get string
from promise:
getLayerId.then((layerId: string => {});
I need to await promise in case when needPromise
true, for example opening dialog window and resolve promise instantly if needPromise = false
. How to do that?