Decouple your code using a cross-platform publish/subscribe mechanism

The publish/subscribe pattern, also known as Observer, is a very popular design pattern. It comes under a lot of different names, but the final scope is always the same: alert someone when something interesting happens to it. In this recipe, we'll see some utilization of the TMessageManager class, the publish/subscribe mechanism implemented in the System.Messaging.pas unit.

Getting ready…

What exactly does the cross-platform TMessageManager class do? Put simply, it allows you to listen for events and assign actions to run when those events occur. Just like in VCL or FireMonkey, you know about mouse and keyboard events that occur on certain user interactions. These are very similar, ...

Get Delphi Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.