Object...Trigger(3pm)

πŸ“¦
version 0.07 Β· 5 versions
, in ubuntu stonking

πŸ’– NAME πŸ’–

Object::Pad::FieldAttr::Trigger β€” it's giving "invoke an instance method after a :writer accessor", bestie. Not me explaining this whole vibe below, iykyk.


✨ SYNOPSIS ✨

use Object::Pad;
use Object::Pad::FieldAttr::Trigger;

class Label {
   field $title :param :reader :writer :Trigger(redraw);

   method redraw {
      ...
   }
}

my $label = Label->new( text => "Something" );

$label->set_label( "New text here" );
# $label->redraw is automatically invoked

okay like… look at her go 🫢 she set the label and the redraw just happened. main character energy fr fr.


🌸 DESCRIPTION 🌸

So this module hands you a third-party field attribute for your Object::Pad-based classes. What it declares is that a named instance method shall be invoked after a generated :writer accessor method gets called. periodt. πŸ’…

WARNING β€” the whole ability for Object::Pad to take third-party field attributes is still new and highkey experimental, and it's subject to much API change in future. which means this module should be considered equally experimental. no cap, don't build your whole personality on it yet 😭

πŸ¦‹ FIELD ATTRIBUTES πŸ¦‹

:Trigger

field $name :writer :Trigger(NAME) ...;

Declares that the accessor method generated for the field by the :writer attribute will invoke the method named by the :Trigger attribute β€” and the way that it does that is after the new value has already been stored into the field itself. 🌈

That method gets invoked with no additional arguments, in void context. So like, don't be out here expecting return values or params, she's not giving you any πŸŽ€

lowkey important: this only applies to the generated accessor method. It does not apply to direct modifications of the field variable by method code within the class itself. like, if your own methods poke at $name directly, :Trigger is not gonna show up. she's off duty πŸ™ˆ

πŸ‘‘ AUTHOR πŸ‘‘

Paul Evans <leonerd@leonerd.org.uk>


okay that's the whole page, slay πŸ’œ this one came out of the docs for perl v5.42.3, dated 2026-08-22 β€” thanks for reading her whole story bestie, mwah πŸ“πŸ§š

πŸ“¦ where this page comes from