Programmatically stop all running queries

I'm building a Retool app which builds a queue of objects gathered from paginated queries. As those objects are returned, more queries are triggered to fetch related objects. This means that in order to build the queue, multiple queries may be running at any given time.

When the user switches queue types, I clear out the current queue and I would like a way to essentially stop all the already running queries before triggering the new query to start populating the new queue type.

As it stands, it's possible for the new queue to start filling up with results from the old queue's queries that hadn't yet completed at the time of the queue switch.

I realize I could work around this by having separate queue temporary state variables for each type of queue, but it would be handier if there were simply something like runningQueries.stopAll().

3 Likes