You can use a feedback loop to store and build upon a result over time. This example composition demonstrates ( ):
Starting with the image from Fetch Image, this composition adds another twirl to the image with each display refresh. Over time, the entire image accumulates twirls upon twirls.
The orange and gray nodes, and the cables between them, comprise the feedback loop. Let’s focus on the part of the loop that stores and repeatedly processes the image: Hold Value, Select Latest, and Twirl Image. Each time Fire on Display Refresh fires an event:
The event enters the Hold Value node’s Update input port.
The Hold Value node executes, outputting the event plus the image produced the previous time around the loop (or an empty image if this is the first time around).
The event plus image enters the Select Latest node’s Option 2 input port.
The Select Latest node executes, outputting the event plus the image from Hold Value (or the original image from Fetch Image if this is the first time around).
The event plus image enters the Twirl Image node’s Image input port.
The Twirl Image node executes, outputting the event plus an image with one additional twirl.
The event plus image hits the Hold Value node’s Value input port.
The Hold Value node executes, although it doesn’t have any visible effect. It doesn’t output any event or data because the event is blocked at the input port’s event wall.
With each event fired from Fire on Display Refresh, these steps repeat and the image gains another twirl.
For each event from Fire on Display Refresh, when exactly does the Hold Value node output an image to Render Image to Window? The first time Hold Value executes, the second time, or both times? The answer is: Only the first time.
The first time Hold Value executes:
The event hits the Update input port.
The node executes.
The event plus data travels out of the output port through all connected cables, including the one to Render Image to Window.
The second time Hold Value executes:
The event hits the Value input port.
The node executes.
Nothing further happens. The event is blocked by the wall on the input port.