Open cannawen opened 1 year ago
In passing back the trigger and given in an array, we lose any semblance of typing. Can this be fixed?
I've noticed one problem with writing rules like this is if
logic for state
In one rule it's very easy to write if-else or if-early-return but in little rules, you have to write the if statement in a when
block and then the else statement in a separate when
block (or the !if & return logic in a separate block because you can't early return). This creates some duplication and can easily lead to missed logic
Maybe one solution to ^ is that Rule
s can hold onto other Rules that are only run when the parent rule is true. Is this getting too deep!?
The lack of typing caused a bug in #129 where the data structure was a set, but we used it as an array.
Refactor to something like
Break up the rule done into when/action -> #62 Use map to construct rule and get rid of getFn in favour of having [trigger] and [given] values passed back to the when and then -> #64