public void Refresh([CanBeNull] Action <Error> onError = null) { if (_demoImplementation == null) { Balance = new List <VirtualCurrencyBalanceModel>(); UpdateVirtualCurrencyBalanceEvent?.Invoke(Balance); Items = new List <InventoryItemModel>(); UpdateItemsEvent?.Invoke(Items); return; } _demoImplementation.GetVirtualCurrencyBalance(balance => { Balance = balance; UpdateVirtualCurrencyBalanceEvent?.Invoke(Balance); }, onError); _demoImplementation.GetInventoryItems(items => { Items = items; UpdateItemsEvent?.Invoke(Items); }, onError); }
private IEnumerator UpdateVirtualItemsCoroutine(Action <Error> onError = null) { yield return(StartCoroutine(UpdateSomeItemsCoroutine <CatalogVirtualItemModel>( SdkCatalogLogic.Instance.GetCatalogVirtualItems, items => { VirtualItems = items; UpdateItemsEvent?.Invoke(items); }, onError))); }
public void UpdateCatalog(Action <List <ServerlessCatalogItem> > onSuccess = null, Action <Error> onError = null) { List <ServerlessCatalogItem> catalog = GetCatalog(); _items = catalog.Where(i => i.IsVirtualItem()).ToList(); _currencies = catalog.Where(i => i.IsCurrency()).ToList(); UpdateItemsEvent?.Invoke(_items); UpdateVirtualCurrenciesEvent?.Invoke(_currencies); onSuccess?.Invoke(catalog); }
private void HandleInventoryUpdate(Action callback) { AllItems.Clear(); AllItems.AddRange(VirtualItems); AllItems.AddRange(Subscriptions); UpdateVirtualCurrencyBalanceEvent?.Invoke(Balance); UpdateItemsEvent?.Invoke(VirtualItems); UpdateSubscriptionsEvent?.Invoke(Subscriptions); RefreshEvent?.Invoke(); callback?.Invoke(); }
private IEnumerator UpdateVirtualItemsCoroutine(Action <Error> onError = null) { var busy = true; _demoImplementation.GetCatalogVirtualItems(items => { VirtualItems = items; AllItems.AddRange(items); UpdateItemsEvent?.Invoke(items); busy = false; }, onError); yield return(new WaitWhile(() => busy)); }