Let’s drill in on one concrete example. This is a small part of what I’m working on now. This is frontend workflows. I had initially refactored everything to use backend workflows, but that was a failure, so now I’m moving it all back to the frontend where I can build these big expressions* that eliminate the need for synchronicity but they also just keep getting bigger the more features I add.
(*Example of a big expression. This is only adding two subtotals right now. I expect to have a dozen subtotals soon. Not all visible to the user at once, but a dozen that I need to potentially be calculating. Yes, I could break the page out into multiple, but then I’m maintaining several nearly identical pages…)
Ok, so here’s the workflow I’ll drill in on for this post. It’s super simple, only 3 steps:
Step 1 calculates the individual line item amounts.
Step 2 calculates/modifies a particular line item based on a condition.
Step 3 tallies it all up.
Problem: step 3 is dependent on a result from step 1 but not step 2. Step 2 may or may not fire, so step 3 can’t depend on step 2.
Potential solution 1: make a copy of step 3, (step 4) and give it the same condition that step 2 has, and make step 4 depend on step 2.
Problem with that solution: messy and complicated to maintain.
Actual solution: Add a step 4 which takes the subtotal from line 3 and conditionally adds the one-off discount to the subtotal.
Next problem: how can I know when it’s safe to use line_delivery_subtotal to calculate tax? I can’t wait for a change to line_delivery_subtotal because it might be changed twice. I can’t depend on a result of step 3 only, because step 4 might fire. I can’t depend on result of step 4, because step 4 might not fire.


