Merge data/events from multiple triggers


How to coordinate overlapping event streams

When you have streams of events from multiple triggers flowing through your composition, usually those streams of events have to merge somewhere in the composition.

Sometimes the streams of events just naturally overlap, as in the example below (File > Open Example > Scene > Move Spinning Sphere). The events fired from the Refreshed at Time port on Fire on Display Refresh and the events fired from the Moved To port on Receive Mouse Moves both travel through the Make Transform and Make Sphere nodes to the Render Scene to Window Node.

Other times, you may want to merge the event streams more intentionally. Here’s an example (File > Open Example > Select > Show Arrow Presses) that takes input from key presses on different arrow keys, and displays a message for each one. The Select Latest node lets the events from each arrow key through.

Here’s an example that shows a different way of merging two event streams. This composition (File > Open Example > Data > Store Mouse Position) draws two gradients that each follow the mouse cursor a bit differently. The purple (upper) gradient stays with the mouse all the time. The violet (lower) gradient only updates every 1 second. For the lower gradient, the event streams from Receive Mouse Moves and Fire Periodically merge at the Hold Value node. Unlike the composition in the previous example, which let both event streams through, this composition lets one event stream through and blocks the other. However, the data left by the blocked event stream (from Receive Mouse Moves) gets picked up and carried along downstream by the other event stream (from Fire Periodically).