In this example, I want to return a pending "stop" Promise (1) which deletes an instance's reference to itself (1), and which callee may have pending / queued actions on.
In the case that a stop is currently happening, I want to return that existing, pending promise.
My question is whether or not the initial condition is deterministic and that it will always return a Promise; not undefined.
Since the variable / reference is removed upon completion, I'm curious if an async action could "jump in" between the conditional and the return statement, or if this is forbidden by block execution / precedence.
Thanks
stop () {
if (this.awaitStop) {
return this.awaitStop;
} else {
this.awaitStop = NativeDevice.video.stop(); // Promise
return this.awaitStop.then(() => delete this.awaitStop);
}
}