Recent

Author Topic: Data Aware components or MVVM/MVC controls  (Read 3404 times)

linnemann

  • New Member
  • *
  • Posts: 34
Data Aware components or MVVM/MVC controls
« on: June 29, 2021, 01:07:09 pm »
Have anyone used MVC or MVVM (observer pattern) with BGRAControls?

lainz

  • Hero Member
  • *****
  • Posts: 4449
    • https://lainz.github.io/
Re: Data Aware components or MVVM/MVC controls
« Reply #1 on: July 24, 2021, 07:55:36 pm »
I've used observables with web technologies like Angular that uses rxjs. Basically you subscribe to a future event and data is returned :with the data you update the UI or do anything else.

About this I've designed a new app that does not use observables with Lazarus but is entirely made of custom controls. So I bind the data to the controls in a redraw or assign method that just updates the UI in that control only (header, body, search, total, menu).

Just the main form is designed the others are all created with code.

This produces less bugs, I've just fixed details that the customer wanted to change.

So what I did is a modular application. Components can be reused (and I did it).

Regular events will help you make the most of the things you need.

I forget something, I use widely data events.

Say...

Code: Pascal  [Select][+][-]
  1. TmyEvent = procedure(const data: TmyClass) of object.
  2.  
  3. Property OnMyEvent: TmyEvent read FOnmyevent write FOnmyevent.

Data events works like an observable. You return data when a condition is meet like user interaction or even a download in a separate thread. You can have an error boolean if you want or manage them in separate events.

 

TinyPortal © 2005-2018