NAME

Mojo::FriendFeed - A non-blocking FriendFeed listener for Mojolicious

SYNOPSIS

use Mojo::Base -strict;
use Mojo::IOLoop;
use Mojo::FriendFeed;
use Data::Dumper;

my $ff = Mojo::FriendFeed->new( request => '/feed/cpan' );
$ff->on( entry => sub { say Dumper $_[1] } );
$ff->listen;

Mojo::IOLoop->start;

DESCRIPTION

A simple non-blocking FriendFeed listener for use with the Mojolicious toolkit. Its code is highly influenced by Miyagawa's AnyEvent::FriendFeed::Realtime.

EVENTS

Mojo::FriendFeed inherits all events from Mojo::EventEmitter and implements the following new ones.

entry

$ff->on( entry => sub {
  my ($ff, $entry) = @_;
  ...
});

Emitted when a new entry has been received, once for each entry. It is passed the instance and the data decoded from the JSON response.

error

$ff->on( error => sub {
  my ($ff, $error, $status, $ff_error) = @_;
  ...
});

Emitted for transaction errors. Fatal if not handled. It is passed the instance, the HTTP error message, HTTP status, and the "errorCode" sent from FriendFeed if available. Note that after emitting the error event, the listen method exits, though you may use this hook to re-attach if desired.

$ff->on( error => sub { shift->listen } );

ATTRIBUTES

Mojo::FriendFeed inherits all attributes from Mojo::EventEmitter and implements the following new ones.

request

The feed to request. Default is an empty string.

ua

An instance of Mojo::UserAgent for making the feed request.

url

The (generated) url of the feed. Using the default value is recommended.

username

Your FriendFeed username. If set, authentication will be used.

remote_key

Your FriendFeed API key. Unused unless username is set.

METHODS

Mojo::FriendFeed inherits all methods from Mojo::EventEmitter and implements the following new ones.

listen

Connects to the feed and attaches events. Note that this does not start an IOLoop and will not block.

SEE ALSO

SOURCE REPOSITORY

http://github.com/jberger/Mojo-FriendFeed

AUTHOR

Joel Berger, <joel.a.berger@gmail.com>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Joel Berger

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.