Skip to content

TObservedHook

Observer pattern helper class implementing IFPObserved interface

Declaration

Source position: fpobserver.pp line 33

type

  TObservedHook = class(TObject, IFPObserved)
  public
    constructor CreateSender;
    destructor Destroy;
    procedure FPOAttachObserver;
    procedure FPODetachObserver;
    procedure Changed;
    procedure AddItem;
    procedure DeleteItem;
    procedure CustomNotify;
    procedure FPONotifyObservers;
    property Sender: TObject; {r}
  end;

Inheritance

Implements: IFPObserved

Description

The TObservedHook class provides a simple way to add observer pattern support to any object. It implements the IFPObserved interface and manages a list of observers that implement the IFPObserver interface.

Objects can use this class as a helper to notify observers about changes, item additions, deletions, or custom events. The class handles attaching and detaching observers automatically and provides methods for different types of notifications.

This class is intended to be used as a component within other classes that need to support observation, rather than being used directly as a standalone object.

Properties

Member Visibility Description
Sender read only public Default sender object for notifications
See all Properties

Methods

Member Visibility Description
AddItem public Notifies observers that an item was added
Changed public Notifies all observers that the object has changed
CreateSender public Creates an observer hook with a specified sender object
CustomNotify public Sends custom notification to all observers
DeleteItem public Notifies observers that an item was deleted
Destroy public Destroys the observer hook and notifies all observers
FPOAttachObserver public Attaches an observer implementing IFPObserver interface
FPODetachObserver public Detaches an observer from the notification list
FPONotifyObservers public Core method to notify all observers about operations
See all Methods

See also

Name Description
IFPObserver