NAME
Mojo::UserAgent::Role::PromiseClass - Choose the Promise class used by Mojo::UserAgent
SYNOPSIS
$ua = Mojo::UserAgent->new(...)
->with_roles('+PromiseClass')
->promise_roles('+Repeat'); # add promise features you want
$ua->get_p('http://example.com')
->repeat(sub{...}); # and they show up on every get_p call
DESCRIPTION
Mojo::UserAgent::Role::PromiseClass is a role that allows specifying the promise class to be used for the promise-returning methods like "get_p" in UserAgent and "post_p" in UserAgent, if you want something different from Mojo::Promise.
ATTRIBUTES
Mojo::UserAgent::Role::PromiseClass implements the following attributes.
promise_class
$pclass = $ua->promise_class;
$ua = $ua->promise_class('Mojo::Promise');
Specifieds the class to use for promises returned by "start_p" in User::Agent and all derived routines ("get_p" in User::Agent, "post_p" in User::Agent, ...).
METHODS
Mojo::UserAgent::Role::PromiseClass supplies the following methods:
promise_roles
$ua->promise_roles(@roles);
This is a shortcut to add the specified @roles
to the user agent's promise_class, returning the original User::Agent, equivalent to
$ua->promise_class($ua->promise_class->with_roles(@roles));
For roles following the naming scheme Mojo::Promise::Role::RoleName
you can use the shorthand +RoleName
.
SEE ALSO
Mojo::UserAgent, Mojo::Promise, Mojolicious, Mojolicious::Guides, https://mojolicious.org.
AUTHOR
Roger Crew <wrog@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2019 by Roger Crew.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.