I’m using the CapacitorPurchases
plugin (but any plugin can have this situation) and methods return promises with results.
Normally I use something like
const result = await CapacitorPurchases.getPurchaserInfo();
this.ngZone.run(()=>{
// do something with result
})
now I have a situation where I prefer to use rxjs and “complex” stream pipes with switchMap
and other things. If I write
from( from(CapacitorPurchases.getPurchaserInfo()))
.pipe(switchMap(value=>{
this.a = value;
return this.httpService.call()
})
the content of switchMap
is run outside of the ngZone
context
but if I write
from( from(CapacitorPurchases.getPurchaserInfo()))
.pipe(switchMap(value=>{
this.ngZone.run(()=>{
this.a = value;
})
return this.httpService.call()
})
or other combination, I can lose data.
Do you know if there is a way to create a zone context with a stream pipe?