Button Tap event fires multiple times

It’ll take a bit to explain what I’m doing here, so I’ll start with a question in case it’s simple - is there anything I should watch for when building a screen that should navigate to another instance of itself (same logical screen with different UI based on data.) I am currently using this pattern, and it’s fine on the first screen load, but when navigating among these pages, each subsequent load gets slower and Tap events fire 3 or more times instead of just once.

Here are the details:

I have an app that is made up of several screens that are the same logical screen, but they change based on a page parameter. It’s for a scorekeeping app, and each page in the app must be filled out for a complete score to be recorded.

Each scorekeeping screen (which again is the same logical screen) consists mostly of a repeated Component that contains a row of buttons which themselves are in a Repeat. (All of this is controlled by a JSON definition file.)

Hitting the buttons works as expected when I first load a scorekeeping screen, but if I navigate among the scorekeeping screens (the same logical screen) and back to the original screen, then the buttons fire the component’s Button Tap event three times instead of just once. If I go again to another scorekeeping screen and then return again, the Button Tap event gets fired even more times.

The multiple event fires seem to be related to the fact that the user is navigating between the same logical page. If I navigate “up” out of the scorekeeping area and go back in, the event duplication doesn’t happen. It only happens when I go from one page to another within the scorekeeping function (navigating to different instances of the same logical screen.)

I’ve also noticed that it gets slower each time this happens, presumably due to some accumulation of logic/overhead/calls that’s happening.

Any ideas here? Is there something I can do to “clear out” the memory as I go between instances of the page? I am not opening them as a modal.

Any help would be much appreciated!

App ID: 169788 Screen: “Scale Point Section”

Component with properties

Component’s external Button Tap logic (the alerts are just there for debugging, and the IF is there to keep the extraneous calls from corrupting data):

Component’s internal Button Tap logic:

If you are using the Open Page flow function then it is loading. a new instance of the page. So you could have multiple instances of the same page running in memory at the same time. This may be your problem.
What you want to use instead is Replace Page (you have to get it from the marketplace).

Just reading your answer, I could tell that it was right…hehe. Yes, I tried Replace page, and it works fine. Thanks for bringing that to my attention!

But that makes me wonder where else I should be using Replace instead of Open (and why it isn’t a default option in Appgyver)? It seems like a pretty handy/important option.

I see from the docs that it replaces the page in the stack rather than opening a new page in the stack. I guess you’d use “Open” if you want the user to be able to hit “back” to get to the original page, or Replace otherwise?

That is correct. On my apps I have a “< Back” button nearly every one of my pages which does ‘Navigate Back’ from any Open Page that opened it. I too had to learn this the hard way after discovering that my page logic was all being duplicated in memory many times.