Published on 23 May 2019 by @mathiasverraes
Listen to a stream of events and produce a new event when a value changes.
A consumer is interested in an event stream, but the consumer only wants to know when a particular value changes, and doesn’t care about the events where that value didn’t change. Optionally, the consumer only cares when the value changes more than a given interval.
A second intermediary consumer is placed in front of the original consumer. It acts as a filter, emitting Change Detection Events when the observed value is different from the previous event. It may also ignore changes that are too small for the original consumer.
Change Detection Events are often used in combination with Ephemeral Events.
The producer emits
TemperatureWasMeasured multiple times per second. A consumer is only interested in changes of 1°C or more. An intermediate consumer listens to the
TemperatureWasMeasured events. When an event arrives, it compares the temperature with the temperature from the previous event. If it differs by more than 1°C, it emits a
Follow @mathiasverraes on Twitter.
This work by Mathias Verraes is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 License.