Navigation Menu

Skip to content

Commit

Permalink
no need to show the same use case twice
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Oct 28, 2017
1 parent f0ca264 commit 358b96b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
15 changes: 0 additions & 15 deletions lib/Mojo/IOLoop.pm
Expand Up @@ -456,21 +456,6 @@ Callbacks will be passed along to L<Mojo::IOLoop::Delay/"steps">.
sub { say 'And done after 5 seconds total.' }
)->wait;
# Handle exceptions in all steps
Mojo::IOLoop->delay(
sub {
my $delay = shift;
die 'Intentional error';
},
sub {
my ($delay, @args) = @_;
say 'Never actually reached.';
}
)->catch(sub {
my $err = shift;
say "Something went wrong: $err";
})->wait;
=head2 is_running
my $bool = Mojo::IOLoop->is_running;
Expand Down
21 changes: 3 additions & 18 deletions lib/Mojo/IOLoop/Delay.pm
Expand Up @@ -110,16 +110,16 @@ sub _defer {
my $self = shift;

return unless my $result = $self->{result};
my $cbs = $self->{status} eq 'resolve' ? $self->{resolve} : $self->{reject};
my $cbs = $self->{state} eq 'resolve' ? $self->{resolve} : $self->{reject};
@{$self}{qw(resolve reject)} = ([], []);

$self->ioloop->next_tick(sub { $_->(@$result) for @$cbs });
}

sub _settle {
my ($self, $status) = (shift, shift);
my ($self, $state) = (shift, shift);
return $self if $self->{result};
@{$self}{qw(result status)} = ([@_], $status);
@{$self}{qw(result state)} = ([@_], $state);
$self->_defer;
return $self;
}
Expand Down Expand Up @@ -231,21 +231,6 @@ Mojo::IOLoop::Delay - Promises/A+ and flow-control helpers
}
)->wait;
# Handle exceptions in all steps
Mojo::IOLoop::Delay->new->steps(
sub {
my $delay = shift;
die 'Intentional error';
},
sub {
my ($delay, @args) = @_;
say 'Never actually reached.';
}
)->catch(sub {
my $err = shift;
say "Something went wrong: $err";
})->wait;
=head1 DESCRIPTION
L<Mojo::IOLoop::Delay> is a Perl-ish implementation of
Expand Down

0 comments on commit 358b96b

Please sign in to comment.