You are viewing the version of this documentation from Perl 5.41.1. This is a development version of Perl.

CONTENTS

NAME

Test2::Event::Generic - Generic event type.

DESCRIPTION

This is a generic event that lets you customize all fields in the event API. This is useful if you have need for a custom event that does not make sense as a published reusable event subclass.

SYNOPSIS

use Test2::API qw/context/;

sub send_custom_fail {
    my $ctx = shift;

    $ctx->send_event('Generic', causes_fail => 1, summary => 'The sky is falling');

    $ctx->release;
}

send_custom_fail();

METHODS

$e->facet_data($data)
$data = $e->facet_data

Get or set the facet data (see Test2::Event). If no facet_data is set then Test2::Event->facet_data will be called to produce facets from the other data.

$e->callback($hub)

Call the custom callback if one is set, otherwise this does nothing.

$e->set_callback(sub { ... })

Set the custom callback. The custom callback must be a coderef. The first argument to your callback will be the event itself, the second will be the Test2::Event::Hub that is using the callback.

$bool = $e->causes_fail