Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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