...

/

Windows and Triggers

Windows and Triggers

Learn how windows and triggers are used to group events in a flow and take data out of a flow, respectively.

Introduction

Operations like Flow.reduce/3, group_by/2, and take_sort/3 require all events to complete before they produce a result. After all, we cannot group or sort a list without all the data in the list being available to us. However, what if the data source keeps producing events for a long time or keeps producing events forever? This means we’ll have to wait for a result for either a very long time or indefinitely. To avoid this, Flow introduces windows and triggers. This section will discuss how windows and triggers can help us get progress updates with long-running flows.

Windows

Windows group all events are going through Flow. We can think of windows as folders for events. They allow us to organize data conveniently. So far, we’ve used Flow.Window.global/0, which creates a global window for us by default. Global windows group all events together and ...