I’ve a question I think only a developer can help answer. I tried looking through the code but got lost. I’ll have a deeper look again but maybe someone can answer off the top of their head.
I’ve been experimenting with GenericEventTrigger and it got me to thinking about ways I could use it to make writing rule templates a little easier.
For example, take my Debounce [3.2.0;3.4.0) rule template. Users of this template must both define Item metadata on each Item and put the Item into a Group to trigger the rule.
In the distant past I used to solve this problem by creating a rule that dynamically creates a rule with triggers based on those Items that have the metadata so there’s no need for the Group. In UI rules though (and we are talking templates to UI rules are all I have to work with), I’ve found that when I create a rule through the normal mechanisms it ends up with some special status or other making it so I can delete it or recreate it later. The lack of a “scriptUnloaded” feature in UI rules also means it’s hard to clean up after itself. This is a wholly separate avenue of inquiry and not necessarily the focus of this thread (though I’m open to suggestions, maybe there’s a way to modify a rules’ triggers through the RuleRegistry somehow?).
After returning to some of my old rule templates to rewrite them in JS Scripting and take advantage of new stuff like privateCache and such, I’ve experimented with GenericEventTrigger and wonder if I couldn’t use that coupled with a rule Condition to achieve the same thing. The rule would trigger on all ItemChangedEvents and the Condition would filter out those that do not have the debounce metadata.
I’m certain this is feasible in theory. But at what point would the performance hit become too great? It seems like a lot of processing to pull the metadata for every ItemChangedEvent. I could cache the results and only check it so often to lesson the load. But what’s the overhead to run a Condition Script for every Item Changed Event?
I can’t tell if this is inspired or doomed to fail or if I really should be pushing for some API to modify a managed rule on the fly.