baja/comp/TopicProperty

Defines TopicProperty (not exposed on baja namespace).

Description:
  • Defines TopicProperty (not exposed on baja namespace).

Source:

Methods

equals(obj) → {Boolean}

Description:
  • Indicates whether some other object is equal to this one.

Source:
Inherited From:
Parameters:
Name Type Description
obj Object

the reference object with which to compare.

Returns:

true if this object is the same as the obj argument; false otherwise.

Type
Boolean

equivalent(obj) → {Boolean}

Description:
  • Compare if all of this object's properties are equal to the specified object.

Source:
Inherited From:
Parameters:
Name Type Description
obj baja.Complex
Returns:

true if this object is equivalent to the specified object.

Type
Boolean

get(prop) → {baja.Value}

Description:
  • Return a Property's value.

    Note that when an instance of a Complex is created, auto-generated
    accessors are created to make accessing a frozen Property's value
    convenient (see example).

    Performance notes:

    BajaScript performs "lazy decoding" on Complexes - this means that after a
    Complex is retrieved from the station, its slot values are kept in their
    raw JSON encoding until they are actually needed (by calling get()). This
    helps performance by not spending CPU time decoding values that won't be
    used. It follows that calling getSlot(slot) will be much faster than
    calling get(slot) for the first time, so consider filtering on slots
    rather than on values, if possible, in performance-critical situations. See
    example under getSlots().

Source:
Inherited From:
See:
Example

Note that when an instance of a Complex is created, auto-generated setters are created to make setting a frozen Property's value convenient. The auto-generated setter is in the format of set(first letter is capitalized)SlotName(...).

  // myPoint has a frozen Property named out...
  var val = myPoint.getOut();
  val = myPoint.get('out'); //equivalent
Parameters:
Name Type Description
prop baja.Property | String

the Property or Property name.

Returns:

the value for the Property (null if the Property doesn't exist).

Type
baja.Value

getAgents(isopt, batchopt) → {Promise}

Description:
  • Returns a promise that resolves to the agent list for this Object.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
is Array.<String> <optional>

An optional array of filters to add to the
agent query.

batch baja.comm.Batch <optional>

An optional object used to batch network
calls together.

Returns:

A promise that will resolve with the Agent Info.

Type
Promise

getDisplay(slotopt, cxopt) → {String|null|Promise.<(String|null)>}

Description:
  • Return a display string.

    If a Slot argument is defined, the display value for the Slot will be
    returned. If a Slot argument is not defined, the display value for the
    Complex will be returned.

Source:
Inherited From:
Example

Printing display values of slots

  // myPoint has a Property named out...
  baja.outln('The display string of the out Property: ' + myPoint.getDisplay('out'));

  // or use string formatting:
  return myPoint.getDisplay('out', { precision: 5 })
    .then(function (str) { baja.outln('formatted display string: ' + str); });
Parameters:
Name Type Attributes Description
slot baja.Property | String <optional>

the Slot or Slot name.

cx object <optional>

as of Niagara 4.10, you can pass a context as the
second argument to use for string formatting. When a context is passed,
a Promise will be returned to be resolved with the formatted string.

Returns:

display (or null if none available).

Type
String | null | Promise.<(String|null)>

getDisplayName(slotopt) → {String}

Description:
  • Return a display name.

    If a Slot is defined as an argument, the display name for the slot will
    be returned. If no Slot is defined, the display name of the Complex
    will be returned.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
slot baja.Slot | String <optional>

the Slot or Slot name.

Returns:

the display name (or null if none available).

Type
String

getEventType() → {Type}

Description:
  • Return the Topic's event Type.

Source:
Returns:

event Type (or null if the Topic has no event Type).

Type
Type

getFacets(slotopt) → {baja.Facets}

Description:
  • Return the Facets for a Slot.

    If no arguments are provided and the Complex has a parent, the
    facets for the parent's Property will be returned.

Source:
Inherited From:
Parameters:
Name Type Attributes Description
slot baja.Slot | String <optional>

the Slot or Slot name.

Returns:

the Facets for the Slot (or null if Slot not
found) or the parent's Property facets.

Type
baja.Facets

getFlags(slotopt) → {Number}

Description:
  • Return Flags for a slot or for the Complex's parent Property.

    If no arguments are provided and the Complex has a parent, the
    flags for the parent's Property will be returned.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
slot baja.Slot | String <optional>

Slot or Slot name.

Returns:

the flags for the Slot or the parent's Property flags.

Type
Number

getIcon() → {baja.Icon}

Description:
  • Return the Object's Icon.

Source:
Inherited From:
Returns:
Type
baja.Icon

getName() → {String}

Description:
  • Return the name of the Component.

    The name is taken from the parent Component's Property for this
    Component instance.

Source:
Inherited From:
Returns:

name (null if not mounted).

Type
String

getParent() → {baja.Complex}

Description:
  • Return the parent.

Source:
Inherited From:
Returns:

parent

Type
baja.Complex

getParentComponent() → {baja.Component|null}

Description:
  • Get the nearest ancestor of this object which is
    an instance of Component. If this object is itself
    a Component, then return this. Return
    null if this object doesn't exist under a Component.

Source:
Since:
  • Niagara 4.10
Inherited From:
Returns:
Type
baja.Component | null

getPropertyInParent() → {baja.Property}

Description:
  • Return the Property in the parent.

Source:
Inherited From:
Returns:

the Property in the parent (null if not mounted).

Type
baja.Property

getSlot(slot) → {baja.Slot}

Description:
  • Return the Slot.

    This is useful method to ensure you have the Slot instance instead of the
    Slot name String. If a Slot is passed in, it will simply be checked and
    returned.

Source:
Inherited From:
Parameters:
Name Type Description
slot baja.Slot | String

the Slot or Slot name.

Returns:

the Slot for the Component (or null if the
Slot doesn't exist).

Type
baja.Slot

getSlots(filteropt) → {module:baja/comp/SlotCursor}

Description:
Source:
Inherited From:
See:
Examples
// A Cursor for Dynamic Properties
  var frozenPropCursor = myComp.getSlots().dynamic().properties();

  // A Cursor for Frozen Actions
  var frozenPropCursor = myComp.getSlots().frozen().actions();

  // An Array of Control Points
  var valArray = myComp.getSlots().properties().is("control:ControlPoint").toValueArray();

  // An Array of Action Slots
  var actionArray = myComp.getSlots().actions().toArray();

  // An Object Map of slot name/value pairs
  var map = myComp.getSlots().properties().toMap();

  // The very first dynamic Property
  var firstProp = myComp.getSlots().dynamic().properties().first();

  // The very last dynamic Property
  var lastProp = myComp.getSlots().dynamic().properties().last();

  // The very first dynamic Property value
  var firstVal = myComp.getSlots().dynamic().properties().firstValue();

  // The very first dynamic Property value
  var lastVal = myComp.getSlots().dynamic().properties().lastValue();

  // All the Slots that start with the name 'foo'
  var slotNameCursor = myComp.getSlots().slotName(/^foo/);

  // Use a custom Cursor to find all of the Slots that have a particular facets key/value
  var custom = myComp.getSlots(function (slot) {
     return slot.isProperty() && (this.getFacets(slot).get("myKey", "def") === "foo");
  });

  // Same as above
  var custom2 = myComp.getSlots().filter(function (slot) {
     return slot.isProperty() && (this.getFacets(slot).get("myKey", "def") === "foo");
  });
  
  // All Slots marked summary on the Component
  var summarySlotCursor = myComp.getSlots().flags(baja.Flags.SUMMARY);

  // Call function for each Property that's a ControlPoint
  myComp.getSlots().is("control:ControlPoint").each(function (slot) {
    baja.outln("The Nav ORD for the ControlPoint: " + this.get(slot).getNavOrd();
  });
<caption>You may see better performance if you can filter on slots
instead of on values.<caption>

// slower
var links = component.getSlots().toValueArray()
  .filter(function (value) { return value.getType().is('baja:Link'); });

// faster - this avoids unnecessarily decoding every non-Link slot
var links = component.getSlots().is('baja:Link').toValueArray();
Parameters:
Name Type Attributes Description
filter function <optional>

function to filter out the Slots we're not interested in.
The filter function will be passed each Slot to see if it should be
be included. The function must return false to filter out a value and true
to keep it.

Returns:

a Cursor for iterating through the
Complex's Slots.

Type
module:baja/comp/SlotCursor

getType() → {Type}

Description:
  • Get the type of this instance.

Source:
Inherited From:
Returns:
Type
Type

getTypeDisplayName(cxopt) → {Promise.<string>|string}

Description:
  • Gets the friendly type display name for this object.

Source:
Since:
  • Niagara 4.10
Inherited From:
See:
  • baja.Type#getDisplayName
Parameters:
Name Type Attributes Description
cx Object <optional>

a context to be passed down to Type

Returns:

If no context is provided, the type
display name is returned synchronously as a string. If context provided,
the type display name is resolved via a promise as a string.

Type
Promise.<string> | string

getValueOf(prop)

Description:
  • Return the result of valueOf on the specified Property's value.
    If valueOf is not available then the Property's value is returned.

Source:
Inherited From:
See:
Parameters:
Name Type Description
prop baja.Property | String

the Property or Property name.

Returns:

the valueOf for the Property's value or the Property's
value (null if the Property doesn't exist).

has(prop) → {Boolean}

Description:
  • Return true if the Slot exists.

Source:
Inherited From:
Parameters:
Name Type Description
prop baja.Property | String

the Property or Property name

Returns:
Type
Boolean

isAncestorOf(comp) → {boolean}

Source:
Since:
  • Niagara 4.12
Inherited From:
Parameters:
Name Type Description
comp baja.Complex | *

the descendent complex to test

Returns:

if this Complex is an ancestor of the given Complex (but not the same
instance). Returns false if the given parameter is not actually a Complex.

Type
boolean

loadSlots(objopt) → {Promise}

Description:
  • Load all of the Slots on the Complex.

Source:
Inherited From:
See:
Parameters:
Name Type Attributes Description
obj Object <optional>

the object literal for the method's arguments.

Properties
Name Type Attributes Description
ok function <optional>

(Deprecated: use Promise) the ok function
callback. Called once network call has succeeded on the Server.

fail function <optional>

(Deprecated: use Promise) the fail function
callback. Called if this method has an error.

batch baja.comm.Batch <optional>

if defined, any network calls will be
batched into this object.

Returns:

a promise to be resolved when the slots have been
loaded.

Type
Promise

newCopy(exactopt) → {baja.Complex}

Description:
  • Create a clone of this Complex.

    If the exact argument is true and this Complex is a Component then
    the defaultOnClone and removeOnClone flags will be ignored.

Source:
Inherited From:
Parameters:
Name Type Attributes Default Description
exact Boolean <optional>
false

flag to indicate whether to create an exact copy

Returns:

cloned Complex.

Type
baja.Complex

propertyValueToString(slot, cxopt) → {Promise.<String>}

Description:
  • Utilize the slot facets, context, and slot to resolve the proper toString.

Source:
Since:
  • Niagara 4.11
Inherited From:
Parameters:
Name Type Attributes Description
slot baja.Property | String
cx object <optional>

the context

Throws:

if the slot name isn't a Property.

Type
Error
Returns:
Type
Promise.<String>

set(obj) → {Promise}

Description:
  • Set a Property's value.

    If the Complex is mounted, this will asynchronously set the Property's
    value on the Server.

Source:
Inherited From:
Examples

An object literal is used to specify the method's arguments.

  myObj.set({
    slot: "outsideAirTemp",
    value: 23.5,
    batch: myBatch // if defined, any network calls will be batched into this object (optional)
  })
    .then(function () {
      baja.outln('value has been set on the server');
    })
    .catch(function (err) {
      baja.error('value failed to set on the server: ' + err);
    });

Note that when an instance of a Complex is created, auto-generated setters are created to make setting a frozen Property's value convenient. The auto-generated setter is in the format of set(first letter is capitalized)SlotName(...).

  // myPoint has a Property named outsideAirTemp...
  myObj.setOutsideAirTemp(23.5);
  
  // ... or via an Object Literal if more arguments are needed...
  
  myObj.setOutsideAirTemp({ value: 23.5, batch: myBatch })
    .then(function () {
      baja.outln('value has been set on the server');
    });
Parameters:
Name Type Description
obj Object

the object literal for the method's arguments.

Properties
Name Type Attributes Description
slot baja.Property | String

the Property or Property name
the value will be set on.

value

the value being set (Type must extend baja:Value).

ok function <optional>

(Deprecated: use Promise) the ok function
callback. Called once the network call has succeeded on the Server.

fail function <optional>

(Deprecated: use Promise) the fail function
callback. Called if this method has an error.

batch baja.comm.Batch <optional>

if defined, any network calls will be
batched into this object.

cx <optional>

the Context (used internally by BajaScript).

Returns:

a promise that will be resolved once the value has been
set on the Complex. If the complex is mounted, will be resolved once the
value has been saved to the server.

Type
Promise

toString() → {String}

Description:
  • Return the String representation.

Source:
Inherited From:
Returns:
Type
String

valueOf() → {*}

Description:
  • Return the inner value of the object.

    By default the object's instance is returned.

Source:
Inherited From:
Returns:

the inner value of the object or just the object's instance.

Type
*