I have an injectable service which performs BLE scans and streams the results through an observable to the page component where it is then stored in a local variable and displayed (in theory).
The issue is that updates coming from the startScanWithOptions
method do not cause the view to be updated, while updates from the setInterval
method do cause an update of the view. The update is making it to the page component as all updates are being written to the console, but not showing up until the setInterval
updates cause a render.
From the injectable service:
start() {
this.connections$ = new Observable((observer) => {
if (this.blePlugin) {
this.blePlugin.startScanWithOptions(
[],
{ reportDuplicates: true },
(result) => this.observableScanResult(result, observer)
);
}
setInterval(()=>{this.observableScanResult({rssi: 100}, observer)}, 1000);
});
return this.connections$;
}
private observableScanResult(result, observer) {
observer.next(result);
}
From the page component:
private startSelection() {
console.log('Scan Starting');
this.connectionSource = this.connection.start();
this.connectionSub = this.connectionSource.subscribe((result) => {
this.test.push(result.rssi);
console.log(this.test);
});
}