Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Reactive-Extensions/RxToBand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

RxToBand

Reactive Extensions (Rx) support for the Microsoft Band

Adds a few extension methods for the IBandSensor interface in the Microsoft Band SDK to enable writing reactive queries against the sensors. This is a quick preview of what's possible with Rx and the Band SDK; the APIs provided here are subject to change.

A simple example of a reactive query is shown below:

var lockedHeartrate = from h in heartRate.OnlyWhenWorn(contact)
                      where h.Quality == HeartRateQuality.Locked
                      select h.HeartRate;

Thanks to the compositional nature of Rx, one can write elaborate sensor data analyses in very few lines of code. For example, computing statistics of heart rate using Window and aggregation operators:

var heartrateStats = (from w in lockedHeartrate.Window(TimeSpan.FromSeconds(60),
                                                       TimeSpan.FromSeconds(10))
                      let d = w.DefaultIfEmpty()
                      from s in Observable.CombineLatest(d.Average(), d.Min(), d.Max(),
                                                         (avg, min, max) => new
                                                         {
                                                             Average = avg,
                                                             Min = min,
                                                             Max = max
                                                         })
                      select s.ToString())
                     .StartWith("Hold on for a minute...");

Have fun!

About

Reactive Extensions (Rx) support for the Microsoft Band

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages