The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Ryu::Async - use Ryu with IO::Async

SYNOPSIS

 #!/usr/bin/env perl
 use strict;
 use warnings;
 
 use IO::Async::Loop;
 use Ryu::Async;
 
 use Log::Any::Adapter qw(Stdout), log_level => 'trace';
 
 my $loop = IO::Async::Loop->new;
 $loop->add(
        my $ryu = Ryu::Async->new
 );
 
 {
        my $timer = $ryu->timer(
                interval => 0.10,
        )->take(10)
         ->each(sub { print "tick\n" });
        warn $timer->describe;
        $timer->get;
 }

DESCRIPTION

This is an IO::Async::Notifier subclass for interacting with Ryu.

METHODS

from

Creates a new Ryu::Source from a thing.

The exact details of this are likely to change in future, but a few things that are expected to work:

 $ryu->from($io_async_stream_instance)
     ->by_line
     ->each(sub { print "Line: $_\n" });
 $ryu->from([1..1000])
     ->sum
     ->each(sub { print "Total was $_\n" });

timer

Provides a Ryu::Source which emits an empty string at selected intervals.

Takes the following named parameters:

  • interval - how often to trigger the timer, in seconds (fractional values allowed)

  • reschedule - type of rescheduling to use, can be soft, hard or drift as documented in IO::Async::Timer::Periodic

Example:

 $ryu->timer(interval => 1, reschedule => 'hard')
     ->combine_latest(...)

source

Returns a new Ryu::Source instance.

SEE ALSO

INHERITED METHODS

IO::Async::Notifier

add_child, adopt_future, can_event, children, configure, configure_unknown, debug_printf, get_loop, invoke_error, invoke_event, loop, make_event_cb, maybe_invoke_event, maybe_make_event_cb, new, notifier_name, parent, remove_child, remove_from_parent

AUTHOR

Tom Molesworth <TEAM@cpan.org>

LICENSE

Copyright Tom Molesworth 2011-2017. Licensed under the same terms as Perl itself.