I agree! That would be really useful, especially for automatically scrolling to the bottom of an repeating group of Messages each time a new Message is added (instead of having to set up a custom state to watch the count)
In the example which watches the Current User’s list of Tags, we first need to set a custom state when the page is loaded to store the total number of Tags in the Current User’s list of Tags. To do this, we can set a custom state for this total number of tags when the page is first loaded:
To set up that custom state (“Total Tags”), I set the custom state on the element “RepeatingGroup MyTags” (but you could choose any element you’d like of course). Since we want to store the number of Tags in the Current User’s list of Tags, I named the custom state “Total Tags” and set it as: (type: number, list: no)
On page load, the value of that “Total Tags” custom state is set to be the Current User’s list of Tags:count.
For example, if the page was loaded and the Current User’s list of Tags:count was 3, this custom state value would be set to 3 (and not change unless we update the custom state again).
In order to ‘monitor’ when there is a change in the Current User’s list of Tags, the “Do When Condition is True” action below is run when the page has fully loaded, and the Current User’s list of Tags:count is not equal to the “Total Tags” custom state value:
Similar to the “Trigger a custom event when data changes” action, this event will run any time there is a change to the Current User’s list of tags:count, since that number will not match the custom state value that was initially set on page load.
For example, if the page was first loaded and the Current User’s list of Tags:count was 3 – then, the Current User removed a Tag from their List of Tags, the Current User’s new list of Tags:count would be 2. However, the custom state would still be set as 3. This would cause the “Do When Condition is True” action to run (since 2 is not 3).
The first action would run (showing the alert), and then the second action updates the custom state from 3 to 2 (in order to match the new, Current User’s list of Tags:count):
Then, if the Current User makes another change (i.e., they subtracted another Tag from their list of Tags, bringing their list’s total from 2 to 1), the “Do When Condition is True” action would run again (since the Current User’s list of Tags:count is 1, and the custom state value was still 2 from before). The alert would show and the custom state would then be updated from 2 to 1 in order to match the Current User’s new list of Tags:count.
That should work! But feel free to let me know if anything was unclear or if you have any questions!