The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Wrangler::PubSub - Wrangler's event hub

DESCRIPTION

A simple EventTable, or a central PublisherSubscriber hub, or a register_hook facility, or...

The rationale: "Don't call specific functions/methods on events (otherwise we'd have to think of all the possible subs that need to be called. Instead we emit pubsub events ('publish' what's going on) and then, in other modules, we decide which events are interesting for this module, and can select the events we want to listen to (subscribe)."

In cases where events are emited from the new() method of modules - as the case in FileBrowser for example - we have a hen and egg problem (race-condition). An event is submitted while another module, which relies on this event, for example, to initialise itself, is not yet "there". For these situations, we have the freeze/thaw mechnism. When PubSub is in 'frozen'-mode, all events get "frozen" - buffered until you call thaw(). This way we can construct widgets, in no particular order, and none of them will miss any events potentially important for them.

CAVEATS

In cases where widgets are added and/or removed on runtime, make sure that your widget classes add a hook with unsubscribe()/ unsubscribe_owner() to Destroy() so that coderefs pointing to a non-existing class get removed from the event table.

SEE ALSO

Kephra::EventTable, Padre::Role::PubSub, Wx::Perl::PubSub

COPYRIGHT & LICENSE

This module is part of Wrangler. Please refer to the main module for further information and licensing / usage terms.