1 package App::Clifton::Component;
3 # define this up here to avoid uninitialised warnings
5 my ($self, $args) = @_;
6 "${self}: ".join ', ', map "$_ => ".$args->{$_}, keys %$args;
9 use Log::Contextual qw(:log);
12 extends 'Moo::Object', 'IO::Async::Notifier';
14 # we're replacing Notifier's constructor so need to set up its default
15 has children => (is => 'bare', default => sub { [] });
18 my ($self, $args) = @_;
20 "Constructing "._debug_self($self, $args);
22 if (my $parent = $args->{parent_component}) {
23 $parent->add_child($self);
28 my ($self, $class, $args) = @_;
29 $class->new(%{$args||{}}, parent_component => $self);
33 my ($self, $code) = @_;
34 $self->get_loop->later($code);
39 log_debug { "Destroying "._debug_self($self, $self) };