Hey all, I was experimenting with using some of FPC's features together and came up with this:
https://github.com/tangentstorm/lazmvc/blob/master/umodel.pas Basically, it's just a generic implementation of the Observer design pattern. It provides a class, TModel, tha you can use as an interface delegate to make any TObject into a subject. (You can also just subclass it.) It also provides GModel<t>, a genericized version of TModel that contains a property, value : T, which notifies observers when that value is is changed. The notification is done through message methods, which means that any TObject can act as an observer and receive callbacks. The rest of that repository is a Lazarus project that demonstrates how to use observers to implement the model-view-controller pattern. The main form provides the view, which is just a little progress bar turned on its side to act like a volume meter. Clicking the "settings" button opens the Controller, which in this case is just a separate form that has a slider control. Because the main form registers itself as an Observer of the model that the controller is managing, moving the slider on the controller causes the main form's View to update in real time. Anyway, it was kind of fun to make and demonstrates some of the more interesting features of ObjFPC, so I thought I'd share. :) You can clone the project through git, or download the whole thing as a zip file from here: https://github.com/tangentstorm/lazmvc/ -michal (aka tangentstorm on #fpc)
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal