How to match dependent events in FRP (in event streams)?

55 Views Asked by At

I’m looking for a pattern, not sure if it exists.

I am working with xstream and I encounter this problem lately. I want to MATCH events based on their causation/dependency on each other.

Let’s say E1 (in Stream1) and E11 (in Stream11) caused E2 (in Stream2). Later, E2 causes E3 (in Stream3). When E3 happens, I want to know which event on Stream1 caused E3, so I am looking for E1, but how do I find it?

I have 3 ideas in theory, 1 seem to be trash in practice.

  1. Every event copies their “parents” data into itself as well, so it's whole history accessible in place. The problem is that it does not scale (loops), reminds me to a COLD stream, but much worse. Nested data, SPACE-heavy.
  2. Every event holds a reference to their “parents” which caused it, so it can be backtracked. Flat data, access for data is computation dependent mainly, but SPACE (infinity history?) must be addressed too.
  3. Creating a dedicated “history” stream (or just a simple list?) which has History Events, which contains the causality information by having references to Events in a shape like: {parents: Event[], child: Event}. Later I can backtrack events by filtering. Or maybe this history container can be more than just a list/stream, but an optimized object for that purpose. SPACE (infinity history?) must be addressed too.

What do you think? Do you have any idea / reference on that issue - maybe something in the FRP world? To me it’s kind of like a “scoping” thing.

This comes up over and over again and to me it looks much worse than me misusing the tools. But maybe I am. :)

0

There are 0 best solutions below