With ConanJs you should be able to write complex interactions easily. There isn't really a single feature that allows for this, but it really is the combination of many of them.
Chaining actions. All actions in ConanJs return an ASAP, so you can guarantee that you can execute logic immediately after the actions is completed.
Composition. Complex use cases many times requires composing actions like, filter, map...
Scoping. Being able to isolate state to operate on it will also help with complex logic.
But there is a key feature that we have not explored yet, Reactions.
You can add reactions to your ConanState by calling addDataReaction. The principle of this very simple, you provide with some logic that will be executed every time the state changes.
stockOrder$ has the buy and sell orders that will trigger alarms
alertsByStock$ the list of alerts by stock key based on stock$ and stockOrder$
alertStream$ as we want to show a list of alerts, we use this derived state to build the list of states based on alertsByStock$ (this is explained further below)
Generating the alerts
Alerts are generated based on any change in either the stock$ or the stockOrder$, below you can see the logic for this.