This article is a reference for configuring a Merge Gate. We recommend reading the introductory merge gates article first. After you've been through the intro and this article, check out the examples documentation, which provides a good reference for accomplishing specific tasks.

Gate Condition and Expression


The gate expression and condition are code expressions which are evaluated at appropriate times. Expressions and conditions are written in Javascript notation and have access to a variety of functions.

Certain values are available for use in the code expression:

  • Each input value can be accessed by the input's name.
  • The timeOf() function returns the timestamp of the given input. If no timestamp is set (i.e. the input has no value yet or has been reset), then it returns null.

For example, suppose a gate has inputs x and y. The following would tell the gate to output the sum only when x and y are both set and positive:

  • Expression: x + y
  • Condition: x > 0 && y > 0 && timeOf('x') && timeOf('y') 


Resetting Input and Output Timestamps

You can control whether input and output timestamps are reset when a new input arrives or when the merge gate outputs a value. This can be used for fine-grained control over when the merge gate output values.

To adjust timestamp reset settings for a port, click on that port then click on the drop-down arrow for the port: 


This opens a pane below the port value that shows conditions for "Reset on Input" and "Reset on Output."

Checking the "Reset on Output" box will reset the timestamp of this port whenever the condition is evaluated as true and a value is sent through the output port. By default, this is unchecked.

Entering the name of other inputs in the "Reset on Input" list will reset the timestamp of this port when those other inputs receive a value, e.g., for port x0, a "Reset on Input" value of ['x1','x2'] will reset the timestamp when either of those ports are triggered.