• Are you stuck on the 500ms interval of grabbing the data? If not, make it 'self invoking': in the place where you know that the callback has completed, place a setTimeout(<startNextGrab>,1). With other asynchronous things going on in a callback - callbacks of a callback and callbacks of their callbacks... you get the point - it is very difficult to find this point. Promises get you out of this.

    Since all javascript is single threaded executed, no two pieces can be run at the same time. Therefore, (pseudo) semaphoring is possible. You could use that to set a variable to true - like skipGrab = true;, and in function invoked by the 500ms interval you check and skip the data grabbing. The challenge though is the same as above: find the place where to clear this flag and set it to false...

    You published only part of the code, so it is not that easy to have a clear pic what to do.

About

Avatar for allObjects @allObjects started