tp.Listener

tp.Listener is a small record object used by Tripous event systems. It stores a callback function, an optional callback context, and a Once flag. Most application code does not need to create listeners directly. Usually a listener is created and returned by methods such as tp.Object.On(), tp.Object.Once(), or tp.AddReadyListener().

The returned listener object is useful because it can later be passed to Off(). This removes exactly that registration, even when the same function is used in more than one place or with a different context.

Direct listener object

A direct new tp.Listener(Func, Context, Once) just stores the three values. The object itself does not call the function. The event owner calls Listener.Func later.

On() returns a listener

tp.Object.On() returns the created listener. Keep that reference and pass it to Off() when you want to remove exactly that listener.

Once() listener

tp.Object.Once() creates a listener with Once = true. After the first event trigger, tp.Object removes it automatically.

Listener state

This status shows how many listeners are currently registered on the demo object.