Custom filter function for event triggers
evaera opened this issue · 4 comments
Is your feature request related to a problem? Please describe.
When creating event triggers, the majority of the on screen options are related to filtering down the event further so it only triggers when you want. But sometimes the options in the UI are not granular enough, or you'd like to filter with some of the UI options in addition to a custom check for simplicity.
In my specific use case, it was recommended that I use a TSU because I want to maintain multiple clones of my aura based on whether or not the event passes my custom filter requirements. While this is possible, it appears that this process will require manually threading through the "dynamic info" from the event into the state. In my specific use case however, it would be easier just to use the "clone per event" option and have the dynamic info automatically generated from the event rather than building it out myself.
Describe the solution you'd like
On event triggers, after all of the built-in filter options, there could be a "Custom filter function" checkbox. When checked, the user is allowed to insert a function which will receive the event arguments and return a boolean as to whether or not the trigger should fire. This function would act in addition to the already present UI filter options, and could be checked last after all of the built in filters are checked. This way, the user can filter with the UI options for simplicity before adding a final check at the end for advanced criteria.
I don’t feel to great about this idea. The number of people who would find this kind of mixture to be more useful than just writing everything themselves is, I think, rather small.
I do have a few ideas on how we could make the trigger interfaces more powerful, by taking a few leaves from the language of the conditions tab (and indeed I would be ok with allowing some custom functions in there too), but that is something on the long term and in the meantime I personally don’t think maintaining a taped on custom script for all event triggers is a great idea.
Well, it's not only about mixing UI options with custom code, it's also about having the "dynamic info" automatically generated. In my specific use case, that's the main thing that I'm after.
But regardless, I would rather use a UI option for ease and clarity and only write what I absolutely must -- but that may just be me being worn out from work all day and wanting to write as little code as possible :)
I don't think we should have a in between normal triggers and custom triggers. If you want custom filtering, then a custom trigger is the way to do it.