It seems like your question is a little unclear, but I believe I have grasped the gist of what you are trying to achieve.
Before proceeding, it's crucial to verify that myEmitter
has a finite nature, meaning it will not run indefinitely. For instance, if you define myEmitter = interval(1000)
, subscribing to it will result in an endless loop, preventing any actions from being executed "after" it.
If we assume that myEmitter
behaves finitely, you can easily utilize the Observable.toPromise
method. Since your code is already within an async
function, the revised snippet would look like this:
const mA = async () => {
try {
const url = myEmitter.toPromise();
getD(url); // remember to await this operation
const la=()=>{...};
return la;
}
catch (error) {
throw error;
}
};
Note: It's worth mentioning that the usage of toPromise
is currently deprecated. Additional information on this matter can be found in this informative blog post.