Tangen...ctProxy(3pm)
β¨ Tangence::ObjectProxy β¨
okay bestie, welcome to Tangence::ObjectProxy, part of the User Contributed Perl Documentation fam π β this is the 3pm one, and it's literally the little proxy bestie that stands in for a Tangence object living over in a Tangence::Client. sit down, grab a strawberry π, we're doing this.
π NAME π
Tangence::ObjectProxy β a proxy for a Tangence object hanging out inside a Tangence::Client. she's not the real thing, she's the representative, and honestly? she's doing amazing.
πΈ DESCRIPTION πΈ
So here's the vibe: instances of this class act as a proxy for an object over in the Tangence::Server. That means you can call methods on it, subscribe to its events, and watch its properties β all from the comfort of your client side. no cap. π«Ά
And listen, these objects do not get constructed by directly calling the new class method. nope, not the move. instead they get returned to you by methods on Tangence::Client, or by methods on other Tangence::ObjectProxy instances. it's giving hand-me-downs but make it β¨networkingβ¨.
Ultimately, every object proxy a client uses comes from one of two places: either the proxy to the registry, or the root object. those are the source, the origin story, the main characters. π
π₯ METHODS π₯
heads up: the following methods, when they're documented inside an await expression, return Future instances. so if you see await, bestie, you're getting a Future back. plan accordingly. β
id
$id = $proxy->id;
returns the object ID for the Tangence object being proxied for. that's it. that's the whole method. iconic behavior honestly.
classname
$classname = $proxy->classname;
returns the name of the class of the Tangence object being proxied for. just the name. the name only. π
class
$class = $proxyobj->class;
returns the Tangence::Meta::Class object that represents the class of this object. so you get the whole meta object, not just a string. upgrade unlocked. π
can_method
$method = $proxy->can_method( $name );
returns the Tangence::Meta::Method object representing the named method, or undef if no such method exists. no method? you get undef. that's the whole deal. π
can_event
$event = $proxy->can_event( $name );
returns the Tangence::Meta::Event object representing the named event, or undef if no such event exists. same energy, different noun. π¦
can_property
$property = $proxy->can_property( $name );
returns the Tangence::Meta::Property object representing the named property, or undef if no such property exists. third time's the charm, we love a consistent trio. β¨
call_method
$result = await $proxy->call_method( $mname, @args );
calls the given method on the server object, passing in the given arguments. returns a Future that will yield the method's result. so you await it and the answer shows up. slay. π
subscribe_event
await $proxy->subscribe_event( $event, %callbacks );
subscribes to the given event on the server object, and installs a callback function that gets invoked whenever the event is fired. π
takes the following named callbacks:
on_fire => CODEβ the callback function to invoke whenever the event is fired:
$on_fire->( @args );
and the returned Future β it is guaranteed to be completed before any invocation of the on_fire event handler. that ordering is not a suggestion, bestie, it's a promise. π
unsubscribe_event
$proxy->unsubscribe_event( $event );
removes an event subscription on the given event on the server object that was previously installed using subscribe_event. the un-subscribe. the reverse. the "we're done here". π«Ά
get_property
await $value = $proxy->get_property( $prop );
requests the current value of the property from the server object. asking nicely, but over the wire. π
get_property_element
await $value = $proxy->get_property_element( $property, $index_or_key );
requests the current value of an element of the property from the server object. one element, hand-picked, very demure. π
prop
$value = $proxy->prop( $property );
returns the locally-cached value of a smashed property. and listen β if the named property is not a smashed property, an exception gets thrown. so don't do that. π¨
set_property
await $proxy->set_property( $prop, $value );
sets the value of the property in the server object. you're not asking this time, you're telling. π
watch_property
await $proxy->watch_property( $property, %callbacks );
watch_property_with_initial
await $proxy->watch_property_with_initial( $property, %callbacks );
watches the given property on the server object, installing callback functions that get invoked whenever the property value changes. the latter form β watch_property_with_initial β additionally ensures that the server will send the current value of the property as an initial update to the on_set event, and it does this atomically when it installs the update watches. no race conditions, we don't know her. π§
takes the following named arguments:
on_updated => CODEβ optional. the callback function to invoke whenever the property value changes:
$on_updated->( $new_value );
if it's not provided, then individual handlers for individual change types must be provided. like, mandatory mandatory. π
the set of callback functions that are required depends on the type of the property. those are documented in the watch_property method of Tangence::Object. go check the source of truth, iykyk. π
watch_property_with_cursor
( $cursor, $first_idx, $last_idx ) =
await $proxy->watch_property_with_cursor( $property, $from, %callbacks );
a variant of watch_property that installs a watch on the given property of the server object, and additionally returns a cursor object that can be used to lazily fetch the values stored in it. lazy girl summer but for data. π
the $from value tells you which end of the queue the cursor should start from:
CUSR_FIRSTβ start at index 0CUSR_LASTβ start at the highest-numbered index
and the cursor is created atomically with installing the watch. package deal, no takebacks. π
unwatch_property
$proxy->unwatch_property( $property );
removes a property watches on the given property on the server object that was previously installed using watch_property. (yes the original says "a property watches", we are being faithful to the text, do not come for me π). anyway β you watched it, now you're done watching it. closure. π¦
π CURSOR METHODS π
the following methods are availilable (yes, availilable β spelling is not her strong suit, but her cursor game? unmatched π
) on the property cursor objects returned by the watch_property_with_cursor method.
next_forward
( $index, @more ) = await $cursor->next_forward( $count );
next_backward
( $index, @more ) = await $cursor->next_backward( $count );
requests the next items from the cursor. next_forward moves forwards towards higher-numbered indices, and next_backward moves backwards towards lower-numbered indices. if $count is unspecified, a default of 1 will apply. one at a time, very chill of her. β¨
the returned future wil (yes, "wil" β we keep it real here) yield the index of the first element returned, and the new elements. and heads up bestie, there may be fewer elements returned than were requested, if the end of the queue was reached. specifically, there will be no new elements if the cursor is already at the end. that's not a bug, that's just the queue ending. π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β the icon, the legend, the one who wrote this whole thing. respect. π
and that's the whole page, bestie!! this was Tangence::ObjectProxy, from perl v5.40.0, dated 2024-09-13, part of the Tangen...ctProxy(3pm) manual (the header truncates it, but we know who she is πΈ). go forth and proxy responsibly. mwah. π
β¨π«Ά
π¦ where this page comes from
- ubuntu resolute: libtangence-perl 0.33-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtangence-perl 0.33-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms