Class: Proxy

olympe.df. Proxy

A Proxy wraps around an other class (e.g. OBoolean, ONumber, OString, ...) inherits its prototype (i.e. all its methods), but intercepts them to build the equivalent Nodes. So creating a Proxy for ONumber, for instance, will let you use all the methods of ONumber but that will build the nodes instead of just executing:

var a = olympe.df.createProxy(olympe.df.ONumber, 10);
var b = b.mul(3);

Note that in this particular case the multiplication is executed immediately once the nodes are created, because both values are fully resolved; However if any of the two numbers had been unresolved at that point (waiting for user input for instance), the multiplication would have been deferred until both 'a' and 'b' were known or 'resolved'.


new Proxy(classToBeProxied, replacementFunction)

Creates a Proxy for the specified class. This should not be used directly in most cases. olympe.df.createProxy is the preferred way to create a proxy.

Parameters:
Name Type Description
classToBeProxied function

Class this proxy will wrap.

replacementFunction function

The interception function to use.

Extends

  • T

Methods


<static> createNew(classToBeProxied, funcToBeCalled)

Creates a fake instance of the proxy class.

Parameters:
Name Type Description
classToBeProxied function
funcToBeCalled function
Returns:

the created proxy.

Type
olympe.df.Proxy.<T>

<static> isProxy(object)

Checks if the specified object is a proxy.

Parameters:
Name Type Description
object *
Deprecated:
  • Use olympe.df.isProxy instead.
Returns:

true if the object is a Proxy

Type
boolean

__assign(data)

This method is a shortcut for assigning values to a data flow, it is useful when switching from dataflow to classic and vice-versa

Parameters:
Name Type Description
data olympe.df.Proxy.<T> | olympe.df.Node.<T> | T
Returns:

This instance

Type
olympe.df.Proxy.<T>

__cast(newType)

removes all the methods of the old proxied object class and add all the methods of the new proxied object

Parameters:
Name Type Description
newType function
Returns:

This instance

Type
olympe.df.Proxy

__clearNodeValue()

Clears the node value

Returns:
Type
olympe.df.Proxy.<T>

__dispose()

Destroys the proxy and the node.


__freeze()

If this Proxy/Node is a repeater, disconnect it from its provider, in essence freezing its value to the current one.


__getCurrentValue()

Nota: use this function with caution, shortcuts all dataflows...

Returns:
Type
T

__getNativeId()

Gets the native ID of this Proxy.

Returns:
Type
number

__getNode()

Returns:
Type
olympe.df.Node.<T>

__getProxyObjectStringRepresentation()

Returns:
Type
string

__getType()

Returns the type of the proxied object.

Returns:

the type of the proxied object

Type
function

__onResolved(onResolvedFunction [, scope] [, returnedType] [, args] [, debugName])

Execute the specified callback every time the value of the associated node changes.

Parameters:
Name Type Argument Description
onResolvedFunction function

function to be called when the node behind this proxy is resolved

scope Object <optional>

scope of the onResolvedFunction when called

returnedType function <optional>

the type that will be returned by the function

args Array <optional>
<nullable>

Arguments to pass to the callback

debugName string <optional>
Deprecated:
Returns:
Type
olympe.df.Proxy.<T2>

__repeat(nodeOrProxy)

Changes this Proxy/Node into a repeater (or pass-through). Such a node forwards the value changes without additional processing.

Parameters:
Name Type Description
nodeOrProxy olympe.df.Node.<T> | olympe.df.Proxy.<T>

The node or proxy to repeat

Returns:

This instance

Type
olympe.df.Proxy.<T>

__setDefaultValue(value)

Sets the default value of this proxy node

Parameters:
Name Type Description
value T | olympe.df.Proxy.<T>
Returns:

This proxy

Type
olympe.df.Proxy.<T>

__setNativeId(uiId)

Sets the native ID of this Proxy.

Parameters:
Name Type Description
uiId number

the new unique ID


__setNode(node)

Parameters:
Name Type Description
node olympe.df.Node.<T>

__setNodeValue(value)

Sets the node value

Parameters:
Name Type Description
value T
Returns:
Type
olympe.df.Proxy.<T>

__setValue(value)

Parameters:
Name Type Description
value T

__toCurrentString()

Gets a string representation of the proxy.

Returns:
Type
string

__withDefaultValue(value)

Creates a new proxy repeating this one with a default value

This function differs from __setDefaultValue in the sense that the initial proxy is left untouched (since this function creates a new proxy), and thus will not carry an initial value (only the repeating proxy will have the initial value). This allows to use the initial proxy (without initial value) somewhere where no default value is required, and the repeating proxy (with default value) somewhere else.

Parameters:
Name Type Description
value T | olympe.df.Proxy.<T>
Returns:
Type
olympe.df.Proxy.<T>

equals(obj)

Creates a node that checks whether this Proxy is equal to the object passed in argument.

Parameters:
Name Type Description
obj *

the object to compare with

Returns:

true if both objects are the same

Type
olympe.df.Proxy.<Boolean>

oEquals(obj)

Creates a node that checks whether the values of the arguments are equal.

Parameters:
Name Type Description
obj *
Returns:
Type
olympe.df.POBoolean