_subscriptions.push( // Update list on OG selection ogViewModel.current$.subscribe( (group) => { this.groupUuid = group.ogUuid; this.groupId = group.id; this.getDevices(); this.getSubOgs(); this.updateGroup(group); }, ),Tengo un bloque de código dentro de subscribe. Sin embargo, parece que no se ejecutan en orden. this.getSubOgs() se ejecuta antes que this.getDevices(). Ambas son llamadas HTTP que devuelven un observable. ¿Cómo me aseguro de que this.getDevices() se ejecute primero? Haga clic para ver los códigos
esto es básicamente la sugerencia de @MishaMashina
_subscriptions.push(ogViewModel.current$.subscribe( (group) => { this.groupUuid = group.ogUuid; this.groupId = group.id; this.getDevices(); this.updateGroup(group); }, ),tanto getDevices() como getSubOgs() siguen siendo métodos separados
en
public getDevices() { this.myApiClient.getDevices().Subscribe( let onlyThisTime: boolean = true; (next) => doStuff (error) => doErrorStuff () => {if(onlyThisTime){this.getSubOgs();}} )}