Example #1
0
        public HiveList()
        {
            this.Title = "BROODMINDER";
            scanner    = DependencyService.Get <IBluetoothScanner> ();

            SetupUI();

            // Original - see all
//			scanner.BroodObservable.Subscribe (btd =>
//				Device.BeginInvokeOnMainThread (() =>
//					ListReadings.Add (new BroodMinderReading (btd))
//				));

            // group by device - distinct elapsed
            var broodObservable = scanner.BroodObservable;

            // Operate
            var broodStream = broodObservable
                              .GroupBy(bt => bt.UUID)
                              .SelectMany(bt =>
                                          bt.DistinctUntilChanged(bte => bte.Elapsed));

            broodStream.Subscribe(bt =>
                                  Device.BeginInvokeOnMainThread(() =>
                                                                 ListReadings.Add(new BroodMinderReading(bt)
                                                                                  )));
        }
Example #2
0
        public HiveList()
        {
            this.Title = "BROODMINDER";
            scanner = DependencyService.Get<IBluetoothScanner> ();

            SetupUI ();

            // Original - see all
            //			scanner.BroodObservable.Subscribe (btd =>
            //				Device.BeginInvokeOnMainThread (() =>
            //					ListReadings.Add (new BroodMinderReading (btd))
            //				));

            // group by device - distinct elapsed
            var broodObservable = scanner.BroodObservable;

            // Operate
            var broodStream = broodObservable
                .GroupBy (bt => bt.UUID)
                .SelectMany (bt =>
                    bt.DistinctUntilChanged (bte => bte.Elapsed));

            broodStream.Subscribe (bt =>
                Device.BeginInvokeOnMainThread (() =>
                    ListReadings.Add (new BroodMinderReading (bt)
            )));
        }