What's the right way to speed up multiple HTTP Request?

sampleuserhere

Active member
I'm trying to replicate my own project from Tasker where one of the things it does is fetching multiple API at once and returns the result to an array.

In Tasker, I could use async fetch to do this with JavaScriptLet action.

How do I replicate this in Macrodroid?

I have tried to loop HTTP Request without blocking the next action but I have a hard time figuring how to store the result to an array with the index being the iterator index.

Anyone can shed me some lights?
 

Endercraft

Moderator (& bug finder :D)
(the macro itself is attached at the bottom of this post)
Try this macro out, which uses action blocks as workarounds :
Fetch_multiple_urls.png
 

Attachments

  • Fetch_multiple_urls.macro
    1.1 MB · Views: 12

sampleuserhere

Active member
(the macro itself is attached at the bottom of this post)
Try this macro out, which uses action blocks as workarounds :
View attachment 4737

It works! However the flow is quite different with what I have in mind. Is it triggering itself when the action block set a variable to different value?

If the flow turns out like what I mention above, How do I wait until all the urls are loaded then?

to give further context, The API I mentioned above is github API. I'm planning to use the API to retrieve latest uploaded apk information. Compare with latest update time of installed app, and then show the notification filled with how many apps has an update.

Thanks to that, I need to wait until everything is loaded to show the notification.

I'm not sure how could I go around this. Maybe like monitoring results[@] array childs count? If it matches the total count of the urls then run actions. Do you think I could do this in Macrodroid?

Edit: I think I got this figured out, I need to use {size=array} to count the total size

Hmm, looks neat so far. i just have to count whether it increases the execution speed or not.

Thankyou very much for the follow up!
 
Last edited:

Endercraft

Moderator (& bug finder :D)
It works! However the flow is quite different with what I have in mind. Is it triggering itself when the action block set a variable to different value?

If the flow turns out like what I mention above, How do I wait until all the urls are loaded then?

to give further context, The API I mentioned above is github API. I'm planning to use the API to retrieve latest uploaded apk information. Compare with latest update time of installed app, and then show the notification filled with how many apps has an update.

Thanks to that, I need to wait until everything is loaded to show the notification.

I'm not sure how could I go around this. Maybe like monitoring results[@] array childs count? If it matches the total count of the urls then run actions. Do you think I could do this in Macrodroid?
Of course you can. Create a variable, set it to [size=urls] when the empty trigger is triggered with a set var action. Then every time the variable change trigger triggers, use an If clause to compare the variable you just created with the expression [size=results] then display a notification in the clause. It should work like that.
 

sampleuserhere

Active member
Of course you can. Create a variable, set it to [size=urls] when the empty trigger is triggered with a set var action. Then every time the variable change trigger triggers, use an If clause to compare the variable you just created with the expression [size=results] then display a notification in the clause. It should work like that.
I see, you explain it well. Thanks to you, I could make this work. Much appreciated!
 
Top