Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async connect() {
this.connecting = true;
this.snackBar.dismiss();
try {
await this.muse.connect();
this.controlResponses = this.muse.controlResponses;
await this.muse.start();
this.data = zipSamples(this.muse.eegReadings)
.takeUntil(this.destroy)
.do(() => this.cd.detectChanges());
this.batteryLevel = this.muse.telemetryData
.takeUntil(this.destroy)
.map(t => t.batteryLevel);
this.muse.accelerometerData
.takeUntil(this.destroy)
.map(reading => reading.samples[reading.samples.length - 1])
.subscribe(this.accelerometer);
} catch (err) {
this.snackBar.open('Connection failed: ' + err.toString(), 'Dismiss');
} finally {
this.connecting = false;
}
}
export const createRawMuseObservable = async () => {
await client.start();
const eegStream = await client.eegReadings;
const markers = await client.eventMarkers.pipe(startWith({ timestamp: 0 }));
return from(zipSamples(eegStream)).pipe(
filter(sample => !sample.data.includes(NaN)),
withLatestFrom(markers, synchronizeTimestamp),
share()
);
};