IO::Eve...Callback(3)

πŸ’– NAME πŸ’–

okay so bestie, welcome to the IO::Eve...Callback(3) page β€” it lives under User Contributed Perl Documentation, and the module is IO::Event::Callback: a closure based API for IO::Event. slay. ✨

πŸŽ€ SYNOPSIS πŸŽ€

here's the vibe, literally copy these exactly:

use IO::Event::Callback;

IO::Event::Callback->new($filehanle, %callbacks);

use IO::Event::INET::Callback;

IO::Event::INET::Callback->new(%socket_info, %callbacks);

use IO::Event::UNIX::Callback;

IO::Event::UNIX::Callback->new(%socket_info, %callbacks);
lowkey yes, $filehanle is spelled like that in the original β€” I'm not touching it, periodt. πŸ’…

🌸 DESCRIPTION 🌸

IO::Event::Callback is a wrapper around IO::Event. it gives you an alternative interface to using IO::Event, and honestly it's giving convenience. πŸ¦‹

instead of defining a class with methods like ie_input, you provide the callbacks as code references when you create the object. main character energy, fr fr.

the keys for the callbacks are the same as the callbacks for IO::Event, except the ie_ prefix is removed. that's it, that's the rule. πŸ‘‘

πŸ¦‹ EXAMPLE πŸ¦‹

use IO::Event::Callback;

my $remote = IO::Event::Callback::INET->new(
       peeraddr        => '10.20.10.3',
       peerport        => '23',
       input           => sub {
               # handle input
       },
       werror          => sub {
               # handdle error
       },
       eof             => sub {
               # handle end-of-file
       },
);
note: IO::Event::Callback::INET, werror, and # handdle error are exactly as the page has them. no edits, no cap. 😭

πŸŽ€ SEE ALSO πŸŽ€

check the source for RPC::ToWorker for an exmaple use of IO::Event::Callback β€” yep, exmaple is the original spelling, and I'm keeping it because details matter. πŸ”₯


mwah πŸ’‹ that's the whole page. it's from perl v5.42.0, dated 2016-12-07, and the footer title is IO::Eve...Callback(3). 🫢

πŸ“¦ where this page comes from