Event:..._Event(3pm)

πŸ’– Event::Distributor::_Event β€” the perl manual page, bestie edition πŸ’–

okay so this is Event:..._Event(3pm) from the User Contributed Perl Documentation, and it's literally the blueprint page for Event::Distributor::_Event, no cap.


✨ NAME ✨

Event::Distributor::_Event β€” it's the base class for Event::Distributor events. the mother of all events, the blueprint, the origin story. periodt.


🌸 DESCRIPTION 🌸

so this class is the base class, and these actual classes below are derived from it, like it's their whole parent situation:

  • Event::Distributor::Signal
  • Event::Distributor::Query

now listen β€” instances of this class are not supposed to be directly created by end-user code. like, that's not the vibe. it's not for you to instantiate yourself, bestie. but it is documented here so we can list out all the shared methods that every subclass gets to have. it's giving "documented for your convenience, not for your constructor calls." πŸ’…


πŸŽ€ METHODS πŸŽ€

subscribe

$event->subscribe( $code )

this one adds a brand new CODE reference that subscribes to the event. that code is expected to return a Future instance. that's the assignment, okay? return a Future. no funny business. πŸ¦‹

subscribers

@codes = $event->subscribers

returns a list of CODE references that were previously subscribed. it's just the whole guest list of everyone who already pulled up. πŸ’œ


πŸ‘‘ EXPECTED METHODS πŸ‘‘

so subclasses are expected to implement the following methods. like, this is the homework. if you're a subclass, you gotta do this:

fire

$f = $event->fire( @args )

this one gets invoked by Event::Distributor to actually run the signal. for real for real, this is the moment. it's expected to invoke any or all subscribers in whatever manner it implements β€” however it wants to do it, that's on the implementation β€” passing arguments as required, and collecting results in some way to provide as the eventual answer of the Future it returns. so: call the subscribers, pass the args, gather the results, hand back a Future that eventually has the answer. iconic behaviour, honestly. πŸ”₯


🫢 AUTHOR 🫢

Paul Evans <leonerd@leonerd.org.uk>


and that's the whole page, babes 🧚 β€” brought to you by perl v5.32.1, dated 2021-09-29, source straight outta the User Contributed Perl Documentation. go forth and not-instantiate this class directly. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from