NAME

Tangence::ObjectProxy - proxy for a Tangence object in a Tangence::Client

DESCRIPTION

Instances in this class act as a proxy for an object in the Tangence::Server, allowing methods to be called, events to be subscribed to, and properties to be watched.

These objects are not directly constructed by calling the new class method; instead they are returned by methods on Tangence::Client, or by methods on other Tangence::ObjectProxy instances. Ultimately every object proxy that a client uses will come from either the proxy to the registry, or the root object.

METHODS

$id = $proxy->id

Returns the object ID for the Tangence object being proxied for.

$classname = $proxy->class

Returns the name of the class of the Tangence object being proxied for.

$proxy->call_method( %args )

Calls the given method on the server object and invokes a callback function when a result is received.

Takes the following named arguments:

method => STRING

The name of the method

args => ARRAY

Optional. If provided, gives positional arguments for the method.

on_result => CODE

Callback function to invoke when a result is returned

$on_result->( $result )
on_error => CODE

Optional. Callback function to invoke when an error is returned. The client's default will apply if not provided.

$on_error->( $error )

$proxy->subscribe_event( %args )

Subscribes to the given event on the server object, installing a callback function which will be invoked whenever the event is fired.

Takes the following named arguments:

event => STRING

Name of the event

on_fire => CODE

Callback function to invoke whenever the event is fired

$on_fire->( @args )
on_subscribed => CODE

Optional. Callback function to invoke once the event subscription is successfully installed by the server.

$on_subscribed->()

If this is provided, it is guaranteed to be invoked before any invocation of the on_fire event handler.

on_error => CODE

Optional. Callback function to invoke when an error is returned. The client's default will apply if not provided.

$on_error->( $error )

$proxy->get_property( %args )

Requests the current value of the property from the server object, and invokes a callback function when the value is received.

Takes the following named arguments

property => STRING

The name of the property

on_value => CODE

Callback function to invoke when the value is returned

$on_value->( $value )
on_error => CODE

Optional. Callback function to invoke when an error is returned. The client's default will apply if not provided.

$on_error->( $error )

$value = $proxy->prop( $property )

Returns the locally-cached value of a smashed property. If the named property is not a smashed property, an exception is thrown.

$proxy->set_property( %args )

Sets the value of the property in the server object. Optionally invokes a callback function when complete.

Takes the following named arguments

property => STRING

The name of the property

value => SCALAR

New value to set for the property

on_done => CODE

Optional. Callback function to invoke once the new value is set.

$on_done->()
on_error => CODE

Optional. Callback function to invoke when an error is returned. The client's default will apply if not provided.

$on_error->( $error )

$proxy->watch_property( %args )

Watches the given property on the server object, installing callback functions which will be invoked whenever the property value changes.

Takes the following named arguments:

property => STRING

Name of the property

want_initial => BOOLEAN

Optional. If true, requests that the server send the current value of the property at the time the watch is installed, in an on_set event. This is performed atomically with installing watch.

on_watched => CODE

Optional. Callback function to invoke once the property watch is successfully installed by the server.

$on_watched->()

If this is provided, it is guaranteed to be invoked before any invocation of the value change handlers.

on_updated => CODE

Optional. Callback function to invoke whenever the property value changes.

$on_updated->( $new_value )

If not provided, then individual handlers for individual change types must be provided.

on_error => CODE

Optional. Callback function to invoke when an error is returned. The client's default will apply if not provided.

$on_error->( $error )

The set of callback functions that are required depends on the type of the property. These are documented in the watch_property method of Tangence::Object.

AUTHOR

Paul Evans <leonerd@leonerd.org.uk>