Skip to content
Browse files

Bump the revision for release. Make little fixes here and there so al…

…l the examples work.
  • Loading branch information...
1 parent 297a698 commit 72d32d4e34db606117d115634b307790427b11b6 @rcaputo committed Apr 23, 2010
View
2 dist.ini
@@ -1,5 +1,5 @@
name = Reflex
-version = 0.005
+version = 0.010
author = Rocco Caputo <rcaputo@cpan.org>
license = Perl_5
copyright_holder = Rocco Caputo
View
8 eg/eg-22-rcb-object.pl
@@ -36,12 +36,12 @@
$self->callback_thing(
ThingWithCallbacks->new(
- cb_object($self, "on_event"),
+ cb_object($self, "event"),
)
);
}
- sub on_event {
+ sub event {
my ($self, $arg) = @_;
eg_say("$self - scalar object handled event");
}
@@ -76,12 +76,12 @@
$self->callback_thing(
ThingWithCallbacks->new(
- cb_object($self, ["on_event"]),
+ cb_object($self, ["event"]),
)
);
}
- sub on_event {
+ sub event {
my ($self, $arg) = @_;
eg_say("$self - array object handled event");
}
View
8 eg/eg-23-rcb-class.pl
@@ -36,12 +36,12 @@
$self->callback_thing(
ThingWithCallbacks->new(
- cb_class(__PACKAGE__, "on_event"),
+ cb_class(__PACKAGE__, "event"),
)
);
}
- sub on_event {
+ sub event {
my ($self, $arg) = @_;
eg_say("$self - scalar class handled event");
}
@@ -76,12 +76,12 @@
$self->callback_thing(
ThingWithCallbacks->new(
- cb_class(__PACKAGE__, ["on_event"]),
+ cb_class(__PACKAGE__, ["event"]),
)
);
}
- sub on_event {
+ sub event {
my ($self, $arg) = @_;
eg_say("$self - array class handled event");
}
View
2 eg/eg-25-rcb-promise.pl
@@ -53,5 +53,5 @@
my $pt = PromiseThing->new( cb_promise(\$promise) );
while (my $event = $promise->wait()) {
- eg_say("wait() returned an event (@$event)");
+ eg_say("wait() returned an event ($event->{name})");
}
View
2 eg/eg-30-promise-timer.pl
@@ -19,5 +19,5 @@
$watcher->observe($timer, cb_promise(\$promise));
while (my $event = $promise->wait()) {
- eg_say("wait() returned an event (@$event)");
+ eg_say("wait() returned an event ($event->{name})");
}
View
2 eg/eg-31-promise-object.pl
@@ -17,5 +17,5 @@
);
while (my $event = $p->wait()) {
- eg_say("wait() returned an event (@$event)");
+ eg_say("wait() returned an event ($event->{name})");
}
View
2 eg/eg-32-promise-tiny.pl
@@ -18,5 +18,5 @@
);
while (my $event = $t->wait()) {
- eg_say("wait() returned an event (@$event)");
+ eg_say("wait() returned an event ($event->{name})");
}
View
2 eg/eg-33-all-callbacks.pl
@@ -129,5 +129,5 @@
);
while (my $event = $pt->wait()) {
- eg_say("promise timer returned an event (@$event)");
+ eg_say("promise timer returned an event ($event->{name})");
}
View
2 lib/Reflex/Callbacks.pm
@@ -75,7 +75,7 @@ sub cb_object {
my ($object, $methods) = @_;
# They passed us a scalar. Emulate cb_methods().
- return($methods => cb_method(@_)) unless ref $methods;
+ return("on_$methods" => cb_method($object, $methods)) unless ref $methods;
# Events match method names.
return( map { ("on_$_" => cb_method($object, $_)) } @$methods ) if (
View
20 lib/Reflex/Trait/Emitter.pm
@@ -2,6 +2,11 @@ package Reflex::Trait::Emitter;
use Moose::Role;
use Scalar::Util qw(weaken);
+has setup => (
+ isa => 'CodeRef|HashRef',
+ is => 'ro',
+);
+
has trigger => (
is => 'ro',
default => sub {
@@ -118,6 +123,21 @@ The "default" option can be used to override the default event emitted
by the Reflex::Trait::Emitter trait. That default, by the way, is the
name of the attribute.
+=head2 setup
+
+The "setup" option provides default constructor parameters for the
+attribute. In the above example, clock() will by default contain
+
+ Reflex::Timer->new(interval => 1, auto_repeat => 1);
+
+In other words, it will emit the Reflex::Timer event ("tick") once per
+second until destroyed.
+
+=head1 CAVEATS
+
+The "setup" option is a work-around for unfortunate default timing.
+It will be deprecated if default can be made to work instead.
+
=head1 SEE ALSO
L<Reflex>
View
10 lib/Reflex/Trait/Observer.pm
@@ -3,6 +3,11 @@ use Moose::Role;
use Scalar::Util qw(weaken);
use Reflex::Callbacks qw(cb_role);
+has setup => (
+ isa => 'CodeRef|HashRef',
+ is => 'ro',
+);
+
has trigger => (
is => 'ro',
default => sub {
@@ -146,6 +151,11 @@ on_clock_tick() method to handle "tick" events from an object with the
The "role" option allows roles to be set or overridden. An observer
attribute's name is its default role.
+=head1 CAVEATS
+
+The "setup" option is a work-around for unfortunate default timing.
+It will be deprecated if default can be made to work instead.
+
=head1 SEE ALSO
L<Reflex>

0 comments on commit 72d32d4

Please sign in to comment.
Something went wrong with that request. Please try again.