Hemi JavaScript Framework
Hemi.wires.primitive
Description
The primitive wire service is used to connect two disparate functions together.
Class Index
- static Hemi.wires.service: Static instance of PrimitiveWireImpl
- Hemi.wires.serviceImpl: A primitive wire connects two functions, where the first function acts as the instigator of an action, and the second function acts as the handler for the action.
static Hemi.wires.service
version 3.1.0
Static instance of PrimitiveWireImpl
Hemi.wires.serviceImpl
version 3.1.0
A primitive wire connects two functions, where the first function acts as the instigator of an action, and the second function acts as the handler for the action.
Index
Example Index
Property Index
- public object_config (internal): Object API structure for storing sub structures: objects and properties.
- public object_id (internal): Unique instance identifier.
- public object_type (internal): The type of this object.
- public object_version (internal): Version of the object class.
- public ready_state (internal): Object load and execution state. Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.
Method Index
- public fireWire: Causes the specified wire to be invoked.
- public getObjectId: Returns the unique id of the object.
- public getObjectType: Returns the type of the object.
- public getObjectVersion: Returns the version of the object.
- public getPointers: Returns the objects sub structure.
- public getPrimitiveWires: Returns an array of primitive wires.
- public getReadyState: Returns the state of the object.
- public getStatus: Returns the properties sub structure.
- public getWire (internal): Returns the wire object based on the specified Identifier.
- public invoke: Invokes a wire, causing the action-handler chain to be processed.
- public sigterm: Sends termination signal to destroy object.
- public wire: Creates and returns a primitive wire based on the specified parameters.
Examples
Wire two functions together
Demonstrate how to wire two functions together with a primitive wire.
Example Code
<script type = "text/javascript">
function Init(){
var _p = Hemi.wires.primitive.PrimitiveWire,w,w2,co;
/// Create a new custom object.
///
co = new CObj();
/// Wire custom object to function test
///
w = _p.wire(co,"testC",0,"test1");
/// Invoke wire #1 connecting custom object to function test2
/// Sending "test data" as a parameter
///
_p.invoke(w,["test data"]);
}
function test(){
alert('test: ' + arguments[0]);
}
function CObj(){
this.id = "XX";
this.testC = function(){
alert("TestC = " + this.id + "\n" + arguments[0]);
return 1;
}
}
</script>Properties
object_config
Object API structure for storing sub structures: objects and properties.
Syntax
object = object.object_config
object_id
Unique instance identifier.
Syntax
String = object.object_id
object_type
The type of this object.
Syntax
String = object.object_type
object_version
Version of the object class.
Syntax
String = object.object_version
ready_state
Object load and execution state. Follows: 0 unitialized, 1 through 3 variant, 4 ready, 5 destroyed.
Syntax
int = object.ready_state
Methods
fireWire
Causes the specified wire to be invoked.
Syntax
void fireWire(
i
)
Parameters
- i as String : Identifier of the primitive wire.
getObjectId
Returns the unique id of the object.
Syntax
i = getObjectId(
)
Returns
i as String: The unique object instance id.
getObjectType
Returns the type of the object.
Syntax
t = getObjectType(
)
Returns
t as String: The type of the object instance.
getObjectVersion
Returns the version of the object.
Syntax
v = getObjectVersion(
)
Returns
v as String: The version of the object instance.
getPointers
Returns the objects sub structure.
Syntax
o = getPointers(
)
Returns
o as object: The objects substructure.
getPrimitiveWires
Returns an array of primitive wires.
Syntax
w = getPrimitiveWires(
)
Returns
w as Array: Array of primitive wire objects.
getReadyState
Returns the state of the object.
Syntax
s = getReadyState(
)
Returns
s as int: The object ready state.
getStatus
Returns the properties sub structure.
Syntax
o = getStatus(
)
Returns
o as object: The properties substructure.
getWire
Returns the wire object based on the specified Identifier.
Syntax
r = getWire(
i
)
Parameters
- i as String : Identifier of the primitive wire.
Returns
r as object: Returns a wire object.
invoke
Invokes a wire, causing the action-handler chain to be processed.
Syntax
r = invoke(
i, a, b, z, p, m
)
Parameters
- i as String : Identifier of the primitive wire to invoke.
- a as array (optional): Arguments to pass to the wired functions.
- b as boolean (optional): Bit indicating the handler should be force-fired even if the action did not evaluate to true.
- z as boolean (optional): Bit indicating the handler should be skipped.
- p as boolean (optional): Bit indicating the wire should be preserved.
- m as boolean (optional): Bit indicating the wire may be used more than once.
Returns
r as boolean: Returns true if the chain completed successfully, false if otherwise.
sigterm
Sends termination signal to destroy object.
Syntax
void sigterm(
)
wire
Creates and returns a primitive wire based on the specified parameters.
Syntax
i = wire(
xp, x, yp, y, ep, e, tl
)
Parameters
- xp as variant : Object, or string evaluation, to which the action function is defined.
- x as function : The action function.
- yp as variant : Object, or string evaluation, to which the handler function is defined.
- y as function : The hander function.
- ep as variant : Object, or string evaluation, to which the error function is defined.
- e as function : The error function.
- tl as String (optional): The label prefix of the wire.
Returns
i as String: Returns the identifier of the primitive wire object.
[ Hemi JavaScript Framework - Stephen W. Cote, 2002 - 2009. ]