COMM.Values

Description

Manages data value synchronization.

Keeps track of all HValue instances present.

Inherits from:

Singleton Methods

implement( interface )

Inherited from: HClass

Description

Copies the members of interface to a HClass or a class inherited from HClass.

Usage:

Defines an interface:
// Create an interface class that calculates the area
var AreaInterface = HClass.extend({
  constructor: null,
  area: function() {
    return this.getWidth() * this.getHeight();
  }
});

// Create a class that contains the coordinates of a rectangle. var Rectangle = HClass.extend({ constructor: function( x, y, width, height ) { this.x = x; this.y = y; this.width = width; this.height = height; }, getWidth: function() { return this.width; }, getHeight: function() { return this.height; } });

// Makes the Rectangle class implement the AreaInterface Rectangle.implement( AreaInterface );


del( id )

Description

Deletes a HValue instance by id.

Parameters

id The unique id of the HValue instance (set by the server)


encode( obj )

Description

Encodes an object to a ascii string (special characters url-encoded).

Parameters

obj Any object

Returns

A String representation of the obj


add( id, value )

Description

Binds a HValue instance created externally to COMM.Values#values. Called from HValue upon construction.

Parameters

id The unique id of the HValue instance (set by the server)
value The HValue instance itself.


set( id, data )

Description

Sets the data of the HValue instance by Id.

Parameters

id The unique id of the HValue instance (set by the server)
data The new data, any Object type supported by JSON.


changed( value )

Description

Marks the HValue instance as changed and tries to send it immediately, unless COMM.Transporter has an ongoing transfer. Usually called by the HValue instance internally.

Parameters

value The HValue instanche that changed.


decode( ibj )

Description

Decodes a JSON object. Decodes url-encoded strings contained.

Parameters

ibj A raw object with special characters url-encoded.

Returns

An version of the object with the contained strings decoded to unicode.


sync( )

Description

Returns an URI-encoded string representation of all the changed values to synchronize to the server.

Returns

An encoded string representation of values to synchronize.


type( obj )

Description

Use this method to detect the type of the object given.

Returns the type of the object given as a character code. Returns false, if unknown or unsupported objcet type.

Returns

One of the following:
  • 'a': Array
  • 'h': Hash (Generic Object)
  • 'd': Date
  • 'b': Boolean (true/false)
  • 'n': Number (integers and floats)
  • 's': String
  • '~': Null
  • '-': Undefined


clone( obj, shallow )

Description

Makes a deep copy of the object.

When you use assignment of a js object, only primitive object types (strings, numbers and booleans) are copied. This method makes a deep (nested) clone of the input object.

Parameters

obj Any object.

Returns

A copy of the object.


create( id, data )

Description

Creates a new HValue instance. Its main purpose is to act as the main client-side value creation interface for the server representation of HValue.

Parameters

id The unique id of the HValue instance (set by the server)
+data The initial data of the HValue instance (set by the server)


s( id, data )

Description

Sets and decodes the data. Main value setter interface for the server representation of HValue.

Parameters

id The unique id of the HValue instance (set by the server)
data The new data from the server, to be decoded.


toString( )

Inherited from: HClass

Protected instance method, returns the instance represented as a String.


valueOf( )

Inherited from: HClass

Protected instance method, returns the value of an instance.


base( )

Inherited from: HClass

This method can be called from any other method to invoke that method's parent



Other Singleton Members

tosync = []

A list of value keys whose value has changed. To be synchronized asap.


constructor = null

No constructor, singleton class.


values = {}

An Object containing all values by key.


prototype = { }

Inherited from: Object

Description

The prototype member of Object defines the instance members. These are copied to the instance object when the new keyword is called.