Tengo el siguiente método:
public classMethod( payload: Payload, ): Observable<Result> { const { targetProp } = payload; let target; return this.secondClass.secondClassMethod({ targetProp }).pipe( delayWhen(() => // some other actions ), ); } Es fundamental establecer este valor target antes de llamar a this.secondClass.secondClassMethod .
¿Es posible llamar a un método asincrónico regular como este?
public classMethod( req: classMethodRequest, ): Observable<classMethodResponse> { const { targetProp } = req; let target; /** ** Calling async method here to set ```target``` ** like ** target = await someAsyncMethod(targetProp) **/ return this.secondClass.secondClassMethod({ targetProp }).pipe( delayWhen(() => ), ); } En otras palabras, me gustaría invocar el método classMethod para que classMethod establezca la variable target dentro de él y luego será posible usar target en la construcción de retorno.
return this.secondClass.secondClassMethod({ targetProp }).pipe( delayWhen(() => ), );He intentado cubrir el método asíncrono en:
from( (async () => { target = await this.someAsyncMethod.setTarget(targetProp); })(), );PERO me dijeron que esta portada invocará en paralelo con
return this.secondClass.secondClassMethod({ targetProp }).pipe( delayWhen(() => ), );paralelo no es una opción aquí :(