package Net::Async::Pusher 0.004;
# ABSTRACT: use with IO::Async
use strict;
use warnings;

use parent qw(IO::Async::Notifier);

=head1 NAME

Net::Async::Pusher - support for streaming event API


 #!/usr/bin/env perl
 use strict;
 use warnings;
 use feature qw(say);
 # For more details, enable this
 # use Log::Any::Adapter qw(Stdout);
 use IO::Async::Loop;
 use Net::Async::Pusher;
 my $loop = IO::Async::Loop->new;
 	my $pusher = Net::Async::Pusher->new
 say "Connecting to via websocket...";
 my $sub = $pusher->connect(
 	key => 'de504dc5763aeef9ff52'
 )->then(sub {
 	my ($conn) = @_;
 	say "Connection established. Opening channel.";
 })->then(sub {
 	my ($ch) = @_;
 	say "Have channel, setting up event handler for 'trade' event.";
 	$ch->subscribe(trade => sub {
 		my ($ev, $data) = @_;
 		say "New trade - price " . $data->{price} . ", amount " . $data->{amount};
 say "Subscribed and waiting for events...";


Provides basic integration with the L<|Pusher> API.


use Net::Async::Pusher::Connection;

=head2 connect

Connects to a server using a key.

 my $conn = $pusher->connect(
  key => 'abc123'

Resolves to a L<Net::Async::Pusher::Connection>.


sub connect {
    my ($self, %args) = @_;
        my $conn = Net::Async::Pusher::Connection->new(
            key => $args{key} // die "need a key"



=head1 AUTHOR

Tom Molesworth <>

=head1 LICENSE

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