Event handler for Web component

Hello.
My question is about the Event handler for Web component.
I make requests to different URLs (which can reply or may not even exist) in cycle without delay using a single instance of the Web component .
Is it acceptable to process all responses to different URLs in one Event handler without any synchronization? Is it really possible that the parameters of the previous response that is currently being processed will be corrupted when the handler receives the next one?
Thanks.

Hello Andrey,

you can use only a Web component to do several calls. You will need to use variable to be able to to distinguish the responses of each request if you want a a differentiated treatment for each request.

Does here in MIT applications exist a queue for events processing?
I'm going to distingish different events in handler by event URL parameter. Is that enough? Can I be sure that other event URL parameter - responseContent - will not be overritten by next response while my app is thinking at previous one?

There is no event processing queue you can manage.

Without further details, I would say yes.

You can use the asynchronous nature of the web component. Send the first request, when you get the response, then send the second request, when you get the response, then send the third request.

how many request do you have?
you can add many Web component, one instance for one request.

Sorry, I didn't understand which solution to prefer.
I'm not going to manage the queue of events, I just wanted to understand how event handler works: it deals with events consistently one by one, or there is no any order and events overlap each other.
You say that variable should be used to process different responses. Which one do you mean?
You confirm that I can be sure that even if I have no synchronization in event handler execution, there will be no overwriting of parameters.
Then you recommend to execute the Web requests and process their responses strictly sequentially. That is, with synchronization.
Unfortunately, working consistently is an obvious, but at the same time the most time-consuming solution.
As a result, what should I do?

Well, I was referring to something like this with the variable to distinguish the responses and, to send one request after the before one:

anyway it depends on what do you want...if the first request fails, do you want to send the next one?
Or, for an easier handling, you can also use different components, like @Kevinkun has suggested, one for each request...

I currently have 7 lighting fixtures controlled in local network via WiFi ESP8266. At any given time, due to the peculiarities of Wi-Fi operation, individual ESP8266S may or may not be available. My application should check their status, display it in the color of the corresponding button, and turn on or off the lighting when the button is pressed. It is desirable that the ESP8266 survey takes place quickly without long synchronization. The number 7 is not final, I want to make a scalable solution with a minimum number of components. The application is almost ready, but there are difficulties with Web events processing.

You probably want something like this:

That is, you suggest using synchronization by global variable. This is a good solution, but as far as I have (for many years) been familiar with computer operating systems, there are usually built-in tools for synchronizing and streamlining processes that do not require user intervention. I was hoping that the same features are available in MIT applications.

Right now my application is organized like this.
There is a list of IP addresses and a corresponding list of their status. Initially, the status is "unavailable".
Starts in a loop accessing to these IP addresses. Some may send reply, some - not.
The Web event handler receives control when response received from IP address, selects an IP address from the URL, determines the IP address number in its table, analyzes the content of the response (enabled or disabled LF) and changes the status indicator under this number in the status list.
That is, there is no external synchronization and the status signs change as responses are received by the handler. If it works with a queue of events without mutual corruption, everything should be fine.

  1. You can use a clock timer instead of a button to "automate" / repeat the process

  2. I didn't provide any blocks to handle the response, only you know what it is you want to do when your get a response back from the url.

The conclusion is this: in order for the application to work reliably, synchronization is needed.
I will keep this in mind, but for now I will still try to debug my algorithm.
Thanks to all the participants for their help.

There are several informed articles on the AI2 thread model at

For those who was interested in this topic.
After reviewing some of proposed articles (thnx to ABG) I realized that MIT supports the creation of queues to event handlers. So I have to find my own mistake! I took a close look at my application and finally discovered a bug that confused me and forced me to contact the community. When processing the Web component response, I was working with the request URL, not the response URL. By the time the response arrived from the first IP address, the address in the request was already the last (seventh). I fixed the error and everything began to work fine.

Thus, events are accumulated, wait in the queue to the handler and do not corrupt each other. Therefore you can issue requests and process responses from Web components without delays and synchronization.

Thanks for telling us what worked!