Detect which dependency changed when using "on" utility with createEffect

Hi, I have the code below:
    createEffect(
        on(
            () => {
                triggerFields.forEach((_trigger) => dataStore[_trigger]);
            },
            () => {
                console.log("EFFECT CALLED");
               // print the name of the triggerField or property 
              // of dataStore which changed and caused this effect to run
            },
            { defer: true }
        )
    );


I have a store called dataStore which is an object with 50+ properties.
I have a string array called triggerFields which correspond to the property names in dataStore.

I want this effect to only run when the trigger fields change. So far I have managed to get this to work by simple accessing the particular properties (i.e the string values in TriggerFields) of dataStore.

However now inside my effect, I actually want to figure out which of my triggerField was responsible for the effect to run.
Any ideas on how I can accomplish this?
Was this page helpful?