> For the complete documentation index, see [llms.txt](https://docs.heisenware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.heisenware.com/concepts/when-streams-meet.md).

# When streams meet

Merging values from several sources, joining branches, looping over lists, and the building blocks with memory and time.

One value flowing from step to step needs no thought. Questions start when an executor takes values from several places, or when one value is a list. This page gives the patterns.

## Six questions

Ask these for any executor with more than one input:

1. **What makes it run?** Decide which values drive the executor and which are only context. See [Triggers and wires](https://docs.heisenware.com/concepts/triggers-and-wires.md#wires).
2. **Where do the other values come from?** From nearby: wire them to the other inputs. From far away, or as state with a name: use a [variable](https://docs.heisenware.com/concepts/variables-and-endpoints.md).
3. **What if a value has not arrived yet?** Give the input a default, or guard the executor with a [filter](https://docs.heisenware.com/app-builder/app-builder/flowboard/filter.md). An input without any value is passed as missing, and many functions fail on that.
4. **The latest value, or each value once?** The latest value is what an input or a variable holds. To consume values one by one, or to collect them, use a building block with memory (below).
5. **How often may it fire?** Use **change** to ignore repeated values and **true** for thresholds. For real debouncing use the `Trigger` class.
6. **Once, or once per element?** A list is passed whole unless you loop over it (below).

## Merging independent streams

Two sensors report on their own, and a calculation needs both. Make both inputs hot: the executor then runs on every value of either stream, each time with the latest value of the other.

<figure><img src="https://3495989837-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE5Ketpww1s7TauSAJrJ8%2Fuploads%2Fgit-blob-2a6285238d704011ca3e9a60b5f78140f2165ac5%2Fconcept-streams-meet.png?alt=media" alt="Two executors polling two machines feed one mergeObjects executor, whose trigger carries two sources, each reading on input update" width="640"><figcaption><p>Two streams meeting: each arrival runs the executor with the latest of the other</p></figcaption></figure>

This is right for anything that describes a state: a sum, a status, a display. Between two arrivals the result is briefly computed from one new and one old value, and that is fine for a state.

It is wrong for effects. If the result sends an email or writes to a machine, one cause would produce two effects, the first of them half updated. Put such a step behind a join, or let it fire on **change** or **true** only.

## Joining branches of one impulse

One click starts two calculations, and a third step needs both results. Set the trigger sources of the third step to **all updated**: it then fires once, when every one of them has delivered, with the values that belong together.

{% hint style="warning" %}
Never put a branch with a filter into such a join. When the filter blocks, that input stays silent and the join waits for it. There is no timeout.
{% endhint %}

The `combine` function of the tools is not a join. It returns the latest value of each of its inputs as one list, as a convenience.

## Loops: once per element

Right-click the trigger and choose **Process One By One**, then the input that holds the list. The executor then runs once per element, one after the other.

* The results come back as one list, in the same order.
* An element that fails becomes its error message in that list. The loop goes on.
* A delay between elements paces calls to a target that accepts only so many per second.

**On all inputs** is the zip loop: every input holds a list of the same length, and the lists are walked together, row by row. With a list of names in the [address](https://docs.heisenware.com/concepts/executors-and-instances.md#addresses-where-a-call-goes), row 1 runs on target 1, row 2 on target 2: ten machines, one executor, one row of inputs each.

A loop is for calling a function per element. To reshape a list, use a [modifier](https://docs.heisenware.com/app-builder/app-builder/flowboard/modifier.md): it maps a whole list in one step. When each element needs several steps, loop over the caller of a [subflow](https://docs.heisenware.com/concepts/subflows.md).

## Building blocks with memory and time

Memory or time with a shape is an instance of one of these classes, never a trick of wiring. All of them are [utility functions](https://docs.heisenware.com/reference/functions/utilities.md) or [storage classes](https://docs.heisenware.com/reference/functions/storage.md).

| Class                                                                                               | What it is                                              | Its events               |
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ------------------------ |
| [`Buffer`](https://docs.heisenware.com/reference/functions/storage/buffer.md)                       | A fixed number of values: a sliding window, or a queue. | `onFull`                 |
| [`Accumulator`](https://docs.heisenware.com/reference/functions/storage/accumulator.md)             | One record assembled from parts that arrive separately. | `onComplete`             |
| [`DataStore`](https://docs.heisenware.com/reference/functions/storage/data-store.md)                | A list of items, shared between Apps by its name.       | `onChange`               |
| [`Counter`](https://docs.heisenware.com/reference/functions/utilities/counter.md)                   | A number that steps up and down.                        | `onChange`               |
| [`Timer`](https://docs.heisenware.com/reference/functions/utilities/timer.md)                       | A countdown.                                            | `onTick`, `onTimeup`     |
| [`Stopwatch`](https://docs.heisenware.com/reference/functions/utilities/stopwatch.md)               | Elapsed time and laps.                                  |                          |
| [`Cron`](https://docs.heisenware.com/reference/functions/utilities/cron.md)                         | A calendar schedule: every Monday at six.               | `onTick`                 |
| [`Trigger`](https://docs.heisenware.com/reference/functions/utilities/event-simulation.md)          | Impulses: by hand, at an interval, debounced.           | `onDebounced` and others |
| [`SignalSimulator`](https://docs.heisenware.com/reference/functions/utilities/signal-simulation.md) | Realistic simulated signals of machines and processes.  | `onTick`                 |

These instances keep their state in memory. What must survive a restart belongs in a [database](https://docs.heisenware.com/concepts/files-data-and-dates.md).

Three rules follow:

* **Time is a source like any other.** Polling is the trigger's own interval. Everything else that depends on time is one of these instances and an [event function](https://docs.heisenware.com/concepts/backend-events.md) on it.
* **Retry with a timer**, not by wiring an output back to its own input.
* **Simulated data comes from a `SignalSimulator`** that feeds the same place the real source will feed, so that replacing it later changes one executor.

## What not to build

Do not let one input's arrival stand for "the other values are there by now". Such logic bets on timing and loses under load. A join says what is meant, and so does an `Accumulator` when the parts come from different places at different times.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.heisenware.com/concepts/when-streams-meet.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
