aui icon indicating copy to clipboard operation
aui copied to clipboard

ADataBinding bad design

Open Alex2772 opened this issue 3 years ago • 0 comments

At the moment, ADataBinding envolves a lot of boilerplate instead of reducing it.

Example usecases

Increase integer field by 1

Expected:

 mViewModel.integerField += 1;

Actual:

 mViewModel.setValue(&ViewModel::integerField, mViewModel->integerField + 1);

Direct and indirect field binding:

Direct binding is almost acceptable:

_new<ALabel>() && mViewModel(&ViewModel::stringField),

But what about label and integer binding?

_new<ALabel>() let {
  mViewModel.addObserver(&ViewModel::integerField, [=](int v) {
    it->setText("The value is: {}"_format(v));
  });
},

Boss music: lists

I.e. I want to make a basic todo app:

struct ViewModel {
  struct Item {
    AString title;
    bool done = false;
  };
  AVector<Item> items;
};

I have no idea how to do this.

Alex2772 avatar Oct 27 '22 18:10 Alex2772