Request for While-loop module

While the repeater module in most cases is enough, I am constantly running into scenarios that would require a While-loop module. So basically a module that would repeat until a condition is met (for example until length(array) == 0 or variableXyz == false). And obviously some sort of control to prevent indefinite loops, maybe with maximum number of iterations etc.

Is this something that others would find usable and has this maybe been requested before?

5 Likes

@vellu
This can be achieved with a combination of filters, the increment function module,//a few other modules

are you suggesting a catchall module to skip these workarounds? or are you stuck without it?

Ok, maybe I’m missing something here but let’s have an example:

I am making an HTTP GET request to a REST API which has poorly designed pagination. I can use limit and offset, but the response I get doesn’t let me know the total amount of records being available. This leads to the need to iterate X times using offset until the result is an empty array.

Because of this I cannot use repeater as I don’t know how many times to repeat. I am aware of workarounds like unnecessarily repeating 1000 times just in case, but this is far from ideal.

What would your suggestion be in this case?

Thanks

I see what you are driving at.

Couple of ways to do this, without being wasteful with api or make resources Right off the top of my head.

scenario is started with a make webhook.
global/team variable or make datastore variable that is a bool(for safety). and a variable for the next pagination step.
if http GET module returns no data, set bool to false. END
if http GET module returns data, check safety bool, set next page, trigger starter webhook again

Bool is there just as safety to kill infinite loop
But not technically required.

There is definitely a more efficient way to do this, but would need to see the specific use case to brainstorm more.