```{index} single: Event::generic ``` # Event::generic ```{pperl-module-badges} Event::generic ``` A generic watcher: an event whenever Perl code says so. Events come from an event source, an `Event::generic::Source` object, whose `event` method gives every active watcher of the source an event; data passed to `event` reaches the callbacks as the event's `data`. The events are `Event::Event::Dataful` objects. `use Event` does not load this watcher type; `use Event::generic` does, and with it `Event::generic::Source`. `Event->generic(%attributes)` (or `Event::generic->new(...)`, or the source's `watch` method) takes the shared attributes of `Event::Watcher` and `source`. A generic watcher repeats. It refuses to start without a callback or without a source ("without source"). ## Synopsis ```perl use Event; use Event::generic; my $source = Event::generic::Source->new; my $w = $source->watch(cb => sub { print "got ", $_[0]->data, "\n" }); $source->event("hello"); Event::sweep(); ``` ## Modules - [`Event::generic::Source`](generic/Source) - An event source for generic watchers (see `Event::generic`): calling its `event` method gives an event to each of its active watchers. ## Functions ### Attributes #### `source` The event source watched: an `Event::generic::Source`, or undef for none. Anything else dies. Changing it moves an active watcher to the new source. ```{toctree} :hidden: :maxdepth: 1 generic/Source ```