apply method

GraphObject apply(
  1. void func(
    1. GraphObject
    )
)

This method takes a function that can be used to apply multiple settings, bindings, or Panel#add calls, to different GraphObjects. This is common in initialization. If you are just adding settings, bindings, or GraphObjects to a single GraphObject, you do not need to use this, you can just chain calls to #set, #bind, and Panel#add instead. This method is mostly useful when setting the same values across multiple GraphObjects.

For example:

// This can be used by several node templates
// to set multiple properties and bindings on each
function nodeStyle(node) {
  node
    .set({ background: 'red' })
    .bind("location")
    .bind("desiredSize", "size", go.Size.parse)
}

// ... in a Node template:
new go.Node("Auto")
 .apply(nodeStyle)
 .add(new go.Shape( ... ))
 .add(new go.Panel( ... ))
 // ...rest of Node template

// ... in another Node template:
new go.Node("Vertical", { padding: 5 })
 .apply(nodeStyle)
 // ...rest of Node template

@since 2.2 @param {((thisObject: this) => void)} func a function that takes this GraphObject @return {GraphObject} this GraphObject @see #set a type-safe method to set a collection of properties

Implementation

_i3.GraphObject apply(void Function(_i3.GraphObject) func) => _i4.callMethod(
      this,
      'apply',
      [_i4.allowInterop(func)],
    );