Sign in Join
FPDoc Onlineexperiment

TObservedHook class

In unit fpObserver

Observer pattern helper class implementing IFPObserved interface

Declaration

pascal
TObservedHook = class(TObject)

Inheritance

  1. TObservedHook
  2. TObject

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.

See also

  • IFPObserver

Properties

SenderpublicDefault sender object for notifications

Methods

CreateSenderpublicCreates an observer hook with a specified sender object
DestroypublicDestroys the observer hook and notifies all observers
FPOAttachObserverpublicAttaches an observer implementing IFPObserver interface
FPODetachObserverpublicDetaches an observer from the notification list
ChangedpublicNotifies all observers that the object has changed
AddItempublicNotifies observers that an item was added
DeleteItempublicNotifies observers that an item was deleted
CustomNotifypublicSends custom notification to all observers
FPONotifyObserverspublicCore method to notify all observers about operations

Fields

FObserversprotected
FSenderprotected

Inherited

From TObject (41)

AfterConstruction BeforeDestruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance Create DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName SafeCallException StringMessageTable SystemHasExtendedRTTI ToString UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.