Skip to content

Instantly share code, notes, and snippets.

@nvandoorn
Created August 21, 2018 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nvandoorn/7e4b43d18cbc5a4979b38878afd5d03c to your computer and use it in GitHub Desktop.
Save nvandoorn/7e4b43d18cbc5a4979b38878afd5d03c to your computer and use it in GitHub Desktop.
class StatsProvider {
private getSwitchedCellStrength(): Observable<number> {
return this.switch$
.switchMap((deviceId: string) =>
this.db
.list(this.paths.sensorStatList(deviceId, CELL_STRENGTH_KEY), {
query: {
orderByChild: 'datetime',
limitToLast: 1
}
})
.takeUntil(this.device.deviceChange$)
)
.filter((stats: Stat<any>[]) => stats != null)
.filter(stats => stats[0])
.map((stats): number => stats[0].val)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment