public ReviewViewModel() { ItemsLoading = BackgroundTaskDescriptor <ReviewViewModel <T>, IEnumerable <T> > .RegisterDescriptor(this, "Ładowanie danych", GetItems) .OnCompleted((vm, res) => { vm.Items = res; }); ItemsLoading.Invoke(); }
public async void LoadItems() { ItemsLoading?.Invoke(); await _apiClient.GetCategories().Process( categories => _items = categories, error => Toast.MakeText(_context, error as string, ToastLength.Long).Show() ); NotifyDataSetChanged(); ItemsLoaded?.Invoke(); }
public async void LoadItems(long cityId, int?page = null) { ItemsLoading?.Invoke(); await _apiClient.GetCityPlaces(1, page : page).Process( places => { _images = new string[places.Length]; Parallel.ForEach(places, async(place, _, index) => _images[index] = await ImageStorage.StoreImage("places", place.Id, place.PhotoUrl) ); _items = places; }, error => Toast.MakeText(_context, error as string, ToastLength.Long).Show() ); NotifyDataSetChanged(); ItemsLoaded?.Invoke(); }
public MetadataViewModel() { ItemsLoading = BackgroundTaskDescriptor <MetadataViewModel <TItem, TEditItem>, IEnumerable <TItem> > .RegisterDescriptor(this, GetLoadingItemsText(), GetItems) .OnCompleted((vm, res) => { vm.Items = new ObservableCollection <TItem>(res); }); EditItemLoading = BackgroundTaskDescriptor <MetadataViewModel <TItem, TEditItem>, TEditItem> .RegisterDescriptor(this, GetLoadingEditItemText(), GetEditItem, Await) .OnCompleted((vm, res) => { vm.EditItem = null; vm.EditItem = res; }); CreateItemLoading = BackgroundTaskDescriptor <MetadataViewModel <TItem, TEditItem>, TEditItem> .RegisterDescriptor(this, GetLoadingEditItemText(), CreateNewItem, Await) .OnCompleted((vm, res) => { vm.EditItem = null; vm.EditItem = res; }); ItemsLoading.Invoke(); }