Routledge

Reactor

Reactor Diagram

What Make an object respond to the proximity of another object.

When The essence of parametric modeling is the definition of object properties in terms of the properties of upstream objects. A problem arises, if the relation between the object and its upstream precedents is based on proximity. The new location for the object becomes based on the old location for the object, making the object definition become circular! And circularity is not allowed in a propagation graph.

Use this pattern when you want to make an object respond to the presence of another object.

Why Designers often use the metaphor of response in which one part of a design depends upon the state of another. Reversing the perspective, it is as if part of a design becomes a tool for shaping the other. This situation is very much like that encountered in the Controller pattern, but with a key difference---the controlling property is proximity.

How The essential idea is simple: connect an interactor to a result through a reference.

The trick is to join the interactor and the result with an intermediary and usually fixed object, which we call a reference. The interactor and the reference interact to produce the result.

For example (see sample "Circle Radii below"), you might have a point and a circle, and you want the circle to get bigger (or smaller or elliptical) as you move the point closer. This can be done by using the Reactor pattern. As you might have guessed, the point is an interactor and the circle is a result (which can be replicated to give us an array of circles). The circles have to be somewhere. This somewhere is the reference. The reference is usually hidden in a Reactor.