Explanation on using subscriptions.

A frame can contain various types of entities. In certain cases, these entities need to exchange data with other entities. This can be achieved through subscriptions.

If an entity needs some data from another entity then it can subscribe to that entity. The target entity can be on the same frame or another frame.

A typical example is where we have a control panel, a model, and a viewer. In this case, we need two subscriptions.

  • The data from the control panel inputs need to be passed to the model.
    • So the model subscribes to the control panel.
  • The data from the model (the geometry that is generated after it solves) needs to be passed to the viewer.
    • So the viewer subscribes to the model.

When configuring a subscription, you need to specify the target entity in the configuration. This is done by specifying three properties:

  • kind: The kind of entity being subscribed to.
  • frame: The name of the frame that contains the target.
  • source: The name of the entity in the contents of that frame.

The subscription may also allow you to configure other aspects that affect the data transfer. For example, when you subscribe a viewer to a model, you can assign materials.

The configuration code below shows a simple example with a control panel, a model, and a viewer.

kind: Solution
version: v0
  kind: Router
    - frame: my-home-frame

    kind: Frame
      kind: ColumnLayout
      widths: [auto, 300px]
      areas: [my-viewer, my-control-panel]

        kind: Model
        subscribe: # subscribe the model to the control panel
          - kind: ControlPanel
            frame: my-home-frame
            source: my-control-panel

        kind: Viewer
        subscribe: # subscribe the viewer to the model
          - kind: Model
            frame: my-home-frame
            source: my-model

        kind: ControlPanel
            kind: Slider
            label: Box height
            min: 2
            max: 10
            precision: 1
            value: 5

Subscription rules

For configuring subscriptions successfully, when the data receiving entity is loaded, the source entity should also be loaded.

For example, entity A can subscribe to entity B if:

  • A and B are in the same frame.
  • A and B are in different frames. When frame A is loaded, frame B is also loaded by necessity.

If a frame has only one child frame, both of them will be loaded. In the example below, entities A and B can be in any frame, since all the frames will be loaded simultaneously.

- Frame1 (has an outlet)
  - Frame2 (has an outlet)
    - Frame3

If a frame has multiple children frames, only one of the children frames and the parent frame will be loaded at the same time. In the example below, Frame2 has 2 children frames, so only Frame3.1 or Frame3.2 will be loaded simultaneously. Therefore, entity A can be in any frame and subscribe to entity B only if entity B is in Frame1 or Frame2.

- Frame1 (has an outlet)
  - Frame2 (has an outlet)
    - Frame3.1
    - Frame3.2