Hey guys, I’m stuck with something and need some advice/help (this might be layer related).
1. I have a set of classes, that form a tree looking like this A -> (B -> C -> D). They communicate
via messages only, so each of them has a “send(message)” method that returns an effect.
2. I can have multiple trees of (B -> C -> D) with the same parent A.
3. I also have a ManagedRuntime set up for the whole app that I use to execute those effects.
The problem:
I’m trying to provide context for subtrees.
For example, we can have multiple subtrees (“branches”) of (B -> C -> D) with
the same parent A.
Ideally, each member of the “B -> C -> D” branch should do something like yield* Context and
get the context. The context can also be changed by each member.
The context should implement the same interface, but each branch should get a “fresh” instance of it.
At the moment, I don’t really understand how to achieve this:
1. I was thinking about using something like Layer.fresh, but couldn’t figure out how to “wrap” a subtree of simple JS classes to make this work.
2. I also thought about putting the Context inside messages themselves but it seems a bit off, because I will have
a lot of them and would probably have to copy the context for each/provide it manually.
Maybe you could suggest some ideas?