public override void DidReceiveLocalNotification(UILocalNotification localNotification, Action<WKUserNotificationInterfaceType> completionHandler) { _compositeDisposable.Dispose(); _compositeDisposable = new CompositeDisposable(); var trade = GetTrade(localNotification); var currencyPair = GetCurrencyPair(localNotification, _priceSubject.AsObservable()); SetupWormholePriceStream(trade); _trader = GetTrader(currencyPair, _priceSubject.AsObservable()); _compositeDisposable.Add(_trader); SetupInterface(trade); SetupStreams(_trader); completionHandler(WKUserNotificationInterfaceType.Custom); }
static LimitedNotificationTrader GetTrader(ICurrencyPair currencyPair, IObservable<PriceDto> priceStream) { var trader = new LimitedNotificationTrader(); trader.Initialize(priceStream, currencyPair); return trader; }
void SetupStreams(LimitedNotificationTrader trader) { trader.PriceStream .Where(price => !price.IsStale) .Subscribe(price => { _price = price; _sellPriceLabel.SetText(price.ToBidPrice().ToAttributedNotificationString()); _buyPriceLabel.SetText(price.ToAskPrice().ToAttributedNotificationString()); }) .Add(_compositeDisposable); trader.PriceStream .Where(price => price.IsStale) .Subscribe(price => { _sellPriceLabel.SetText("-"); _buyPriceLabel.SetText("-"); _priceLabel.SetText(""); }) .Add(_compositeDisposable); trader.PriceStream .Where(price => !price.IsStale) .ToPriceMovementStream() .Subscribe(priceMovement => { _arrowLabel.SetText(priceMovement.ToAttributedArrow(_price)); _priceLabel.SetText(_price.Spread.ToString("0.0")); SetPricesHidden(false); }) .Add(_compositeDisposable); }