Merge gates allow you to merge and otherwise manipulate data in a variety of ways, and help you control exactly when data should be "released" from the gate. Merge gates perform this operation in between components. It's often the case that connecting components requires some adjustment in the output data before it's receivable by the input of the next component. The gate provides an anonymous space to perform these adjustments, e.g.

  • restructuring the data, such as renaming properties;
  • merging multiple data into a single data, such as joining them or concatenating them; and
  • destructuring data.

This article will walk through the basics of merge gates and merge gate user-interface.

Why (or when) a merge gate instead of a component?

Anything you can do with with a merge gate you can do with a component. Merge gates are more apt under the following conditions:

  • An anonymous operation: The operations do not belong in any component. For example, it is not the responsibility of the component outputting the data to ensure that it is compatible with the input of another component, and vice versa. Indeed, a component author knows nothing about how the component will used by another xap builder, and should avoid making assumptions as much as possible.
  • The operation is low-level: The operations are typically about formal, low-level details about the data, such as modifying property names and data structure, performing timing control, etc.
  • You are xap building: The operations are concerns which occur when xap building (i.e. when connecting things together), not component authoring.

What's Merge Gate Made of?

A merge gate has multiple elements:

  1. A set of inputs that contain one or more input ports initially named x0, x1, etc.;
  2. An expression that defines what to output (more on this in a moment);
  3. A condition that determines when to output data; and 
  4. A single output that is the result of the expression.

The merge gate operation works through the elements in that order. When new data arrives to an input port, the condition is evaluated. If the condition is met, the expression is evaluated and the result sent out of the output port.

Working with Merge Gates in Xaps

To create a merge gate, click on the merge arrow icon in the bottom left corner of the Xap Builder:

This creates a blue dot in the middle of the Xap Builder that represents the merge gate:

Clicking on the dot will open the merge gate, allowing you to connect input and output ports and define the expression and condition.


  When you expand a merge gate, other components will rearrange to move out of the way. Don't worry, when you collapse the merge gate, your data flow returns to its prior layout.

To delete an existing merge gate, click the icon
To add an additional port, click the icon
To collapse the merge gate back to the blue dot, click theicon

You can wire the merge gate to other components or other merge gates as needed.

You can also rename the input ports by clicking on the port, clicking on the name in the title bar of the port box, and typing in a new name. Note that the ports will automatically reorder so as to be in alphabetical order.

Expressions and Conditions

Expressions and conditions are written in Javascript notation and have access to a variety of Exaptive functions.

One especially useful method is timeOf. This method takes a single parameter, the input port, e.g. timeOf(x0), and will return an integer timestamp. The timestamp is useful for comparing when different input values have arrived, if that is important for accepting the condition or controlling expression output.

The best way to learn more is to view the Merge Gate Configuration (Merge Gates, Part 2 of 3) and Merge Gate Examples (Merge Gates, Part 3 of 3).

Merge gates also help address a specific timing issue in xaps in cooperation with Composite Inputs. Check out the article on Using Composite Inputs.