Flows
Last updated
Was this helpful?
Last updated
Was this helpful?
The core of the Backstage engine is the Flow Controller. Every module exposes a set of Broadcasters and Listeners. These are presented as Nodes in the Flow Controller interface. These nodes can be dragged onto the canvas, and connected together to form Flows.
Nodes are the building blocks of the Flow Controller. They can be connected together to form behavior systems, called Flows. These can be as simple as:
When the video ends, send the user to the end page
or as complex as:
When the video ends, if the user has attended our events before, but not if they're on our mailing list, send them to the newsletter signup page
.
The underlying architecture is powerful enough to build as many branches, with as many data inputs as needed.
Some nodes have an About
field. This field can take the ID of a module on a page, and cause the Node to only interact with a specific instance of that module. If not provided, it will interact will all Modules of that type on all pages.
For example, a Video:ended
Broadcaster Node will, by default, fire when any Video on any page ends. If provided an ID for the Video module on /end
, it will only fire when that specific video player ends.
A Broadcaster node is fired when the underlying module event occurs.
For example, a Video module has the Broadcaster node Video:ended
. This node fires when the currently playing video ends.
A Broadcaster node can include data which can be used for logic or to create dynamic behavior in a Listener Node.
A Listener node fires when it is pressurized by an upstream node. It triggers an action in the associated module, such as redirecting the user to a new page, or changing the source of a video player.
A Middleware node applies logic to, or changes the input of a node. It passes the new data to its outputs.
A Value node provides a value to a flow. This value can be used in downstream nodes for logic, or to apply dynamic behavior to a Listener node.
A Flow is formed by a series of nodes connected together, starting with at least one Broadcaster, and ending with at least one Listener.
Flows are executed when one or more Broadcaster nodes is fired. Once a Broadcaster has fired, it provides pressure to the flow.
Pressure
In order for a Flow to execute, it needs to be provided Pressure. Pressure flows from left to right in a flow.
Only Broadcaster nodes provide pressure. Value, Middleware, and other nodes do not.
Without Pressure, a Listener node will not fire.
Pressure propagates from the fired Broadcaster node to its children nodes, then on and on until it reaches a Listener node. Pressure can be blocked or redirected by Middleware nodes.
For example, we might want to redirect the user based on the value of their hasAttendee
variable. We can use Middleware nodes to redirect pressure based on some criteria.
If the user variable hasAttended
is false, Pressure flows to Not Equal:
If the user variable hasAttended
is true, Pressure flows to Equal: