Created
May 5, 2014 18:38
-
-
Save mattbarrett/74b13723cbcceed5d7ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void LoadSpotTiles() | |
{ | |
_referenceDataRepository.GetCurrencyPairsStream() | |
.ObserveOn(_concurrencyService.Dispatcher) | |
.SubscribeOn(_concurrencyService.TaskPool) | |
.Subscribe( | |
currencyPairs => currencyPairs.ForEach(HandleCurrencyPairUpdate), | |
error => _log.Error("Failed to get currencies", error)); | |
} | |
private void HandleCurrencyPairUpdate(ICurrencyPairUpdate update) | |
{ | |
var spotTileViewModel = SpotTiles.FirstOrDefault(stvm => stvm.CurrencyPair == update.CurrencyPair.Symbol); | |
if (update.UpdateType == UpdateType.Add) | |
{ | |
if (spotTileViewModel != null) | |
{ | |
// we already have a tile for this currency pair | |
return; | |
} | |
var spotTile = _spotTileFactory(update.CurrencyPair, _config.Config.SubscriptionMode); | |
SpotTiles.Add(spotTile); | |
} | |
else | |
{ | |
if (spotTileViewModel != null) | |
{ | |
SpotTiles.Remove(spotTileViewModel); | |
spotTileViewModel.Dispose(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment