#  You may distribute under the terms of either the GNU General Public License
#  or the Artistic License (the same terms as Perl itself)
#  (C) Paul Evans, 2015-2021 -- leonerd@leonerd.org.uk

package Event::Distributor::_Event 0.06;

use v5.14;
use warnings;

use Future;

=head1 NAME

C<Event::Distributor::_Event> - base class for L<Event::Distributor> events


This class is the base from which the following actual classes are derived:

=over 2

=item *


=item *



Instances of this class shouldn't be directly created by end-user code, but it
is documented here in order to list the shared methods available on all the


sub new
   my $class = shift;
   return bless {
      subscribers => [],
   }, $class;

=head1 METHODS


=head2 subscribe

   $event->subscribe( $code )

Adds a new C<CODE> reference that subscribes to the event. This code is
expected to return a L<Future> instance.


sub subscribe
   my $self = shift;
   my ( $code ) = @_;

   push @{ $self->{subscribers} }, $code;

=head2 subscribers

   @codes = $event->subscribers

Returns a list of C<CODE> references previously subscribed.


sub subscribers
   my $self = shift;
   return @{ $self->{subscribers} };


Subclasses are expected to implement the following methods:


=head2 fire

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

Invoked by L<Event::Distributor> to actually run the signal. This is expected
to invoke any or all subscribers in whatever manner it implements, passing
arguments as required, and collecting results in some way to provide as the
eventual answer of the L<Future> it returns.


=head1 AUTHOR

Paul Evans <leonerd@leonerd.org.uk>