Event::generic(3)

πŸ’– NAME πŸ’–

Event::generic β€” generic event handling. That’s the whole vibe, bestie. ✨

This is the Event::generic(3) page from the User Contributed Perl Documentation, so you already know it’s gonna be a little niche and a little iconic. 🫢

✨ SYNOPSIS ✨

use Event::generic;

$source = Event::generic::Source->new;

$w = Event->generic(source => $source, ...);
$w = $source->watch(...);

$source = $w->source;
$w->source($source);

$source->event;
$source->event($data);

$data = $event->data;

🌸 DESCRIPTION 🌸

Okay so this module gives you a watcher type inside the Event framework. But real talk: you must understand the architecture of the Event system before this document will make sense β€” no skipping the lore, bestie. πŸ’…

It gives you a system of reified event sources and watchers watching those sources. Events are generated solely by a method on the event source object. Those events may carry arbitrary data to the event handler callbacks. This module is intended for situations where the events of interest are best determined by Perl code. It’s giving β€œlet Perl decide what counts as an event,” and honestly? Slay. πŸ’–

πŸŽ€ CLASSES πŸŽ€

  • Event::generic::Source β€” a reified event source. The source of the source, if you will. ✨
  • Event::generic β€” a watcher that can watch Event::generic::Source event sources. πŸ‘€
  • Event::Event::Dataful β€” a (target) event that can carry arbitrary data. Dataful and booked. πŸ“

🌟 EVENT SOURCE CLASS 🌟

🧚 Constructor 🧚

  • Event::generic::Source->new β€” creates and returns a new event source. Fresh source, no cap. 🫢

πŸ’… Methods πŸ’…

  • $source->event
  • $source->event(DATA)

Invoking this method is a source event for watchers of the event source. When this method is called, each active watcher of the event source generates a target event. The DATA, if supplied, is copied into the target event objects, from which it can be retrieved using the data() method. Like passing a little note in class β€” except the note is arbitrary data and the class is event handling. 😭

  • $source->watch(ATTR => VALUE, ...) β€” generates and returns a new watcher, configured to watch this event source. The standard watcher attributes may be specified as arguments. The watcher returned is an ordinary Event::generic, and may be reconfigured to watch a different event source. Reusable watcher? We love a flexible icon. 🌈

πŸ”₯ WATCHER CLASS πŸ”₯

πŸŽ€ Type-specific attributes πŸŽ€

  • source => $source β€” the event source to watch. This must be either an Event::generic::Source object or undef. When set to undef, no source is being watched, and the watcher cannot be started. So if you set it to undef, it’s literally not beating the β€œcan’t start” allegations. πŸ’€

⭐ EVENT CLASS ⭐

πŸ“ Type-specific methods πŸ“

  • $event->data β€” returns the data associated with the event, which may be any scalar. This is read-only, and is set by the event source. So no take-backs, bestie; the source already decided. πŸ™ˆ

🌈 SEE ALSO 🌈

  • Event β€” the main character, obviously. πŸ‘‘

Later, bestie! πŸ’– This page is from perl v5.42.0, dated 2021-04-30 β€” Event::generic(3), mwah. πŸŽ€βœ¨

πŸ“¦ where this page comes from