Back in 2010, in the thread about observer support in fcl, i asked if the actions would be customizable so i could, e.g., notify/observe if a child was added or removed in a tree structure. The answer was yes.
Looking at the recent added support, it limit the actions (called operations) to 5 types
TFPObservedOperation = (ooChanged,ooFree,ooAddItem,ooDeleteItem,ooCustom);I ask to change to a mechanism that could allow customizable operations (more than one)
I'm asking that because i have implemented a similar mechanism that support operations like Load, ChildAdd, ChildDelete, ChildChange. I believe that more developers are in the same situation,i.e., using observer pattern to an action not handled by those 5 types. It would be helpful to use the native implementation otherwise i will have to keep(re-implement) the observer support over TPersistent.
BTW:
The names of the TFPObservedOperation are not consistent: ooChanged is in preterit while others not
ooChanged does not has Item suffix
it should be
ooChange,ooAdd,ooDelete
or
ooChanged,ooAdded,ooDeleted
or
ooChangeItem,ooAddItem,ooDeleteItem
or
ooChangedItem,ooAddedItem,ooDeletedItem
The changes: http://svn.freepascal.org/cgi-bin/viewvc.cgi?view=rev&revision=22257
See the cited email:
Michael Van Canneyt wrote 9 lines
It will send some kind of info (like index or address of the object) to know what and where the item was added or removed?
Yes.
Can the same Obsever observe (:-D) more than of one type of object? e.g. i want to observe a object list for adding or removals, but also want to know if one of the child objects changed.
Yes. You can observe any object that will implement the IFPObservable interface.
Michael.
