private IDisposable BindPackageToggled(IMainPageView view, UserPackageSelectionStore store) { return(view.OnPackageToggled().Subscribe(item => { PahkatApp.Current.Dispatcher.InvokeAsync(async() => { Log.Verbose("Toggle package"); await store.TogglePackageWithDefaultAction(item.Key, !item.IsSelected); }); })); }
private IDisposable BindGroupToggled(IMainPageView view, UserPackageSelectionStore store) { return(view.OnGroupToggled() .Subscribe(tree => { PahkatApp.Current.Dispatcher.InvokeAsync(async() => { Log.Verbose("Toggle group"); var list = new List <PackageKey>(); foreach (var task in tree.Items.Map(x => x.Key.DefaultPackageAction())) { var v = await task; list.Add(v.PackageKey); } await store.ToggleGroupWithDefaultAction(Iter.ToArray(list), !tree.IsGroupSelected); }); })); }
private IDisposable BindPrimaryButton(IMainPageView view) { return(view.OnPrimaryButtonPressed() .Subscribe(_ => { Log.Verbose("Primary button pressed"); var app = PahkatApp.Current; var actions = Iter.ToArray(_store.State.SelectedPackages.Values); Task.Run(async() => { try { await app.PackageStore.ProcessTransaction(actions, value => { Log.Debug("-- New event: " + value); var newState = app.CurrentTransaction.Value.Reduce(value); app.CurrentTransaction.OnNext(newState); }); } catch (Exception e) { _view.HandleError(e); } }); })); }
public MainPagePresenter(IMainPageView view, UserPackageSelectionStore store) { _view = view; _store = store; }
private IDisposable BindPrimaryButtonLabel(IMainPageView view, UserPackageSelectionStore store) { // Can't use distinct until changed here because HashSet is never reset return(store.SelectedPackages() .Subscribe(GeneratePrimaryButtonLabel)); }
public MainPageViewModel(IMainPageView v) { view = v; }
public void SetView(IMainPageView view) { _view = view; _view.OnGetANumberClicked += HandleOnGetANumberClicked; }