FileSystemDirectoryReader.readEntries lets us read the file contents however is it is async in nature and I need to do it in a synchronous way. I have tried using async and that doesn't fit my use case as well. What I want is somewhat similiar to this. Which freezes the main thread.
var request = new XMLHttpRequest();
request.open('GET', '/bar/foo.txt', false); // `false` makes the request synchronous
request.send(null);
if (request.status === 200) {
console.log(request.responseText);
}
I know it is bad user experience but it seems unavoidable at this point.
The use case
We have multiple event handlers listening to the drop event. I need to so some processing in my event handler (It's guaranteed to be the first one to receive) based on which I can decide whether the other event handlers should not process the event using event.stopImmediatePropagation
but if I am doing stuff which is async the other handlers receive and continue to process the event even if I decide to stop propagation. I have no control over the other handlers and cant modify their code
I have tried stopping the propagation before my async call and dispatch the event after processing but that is proving to be difficult as the event.dataTransfer
is empty and the other event handlers are not getting the files. Force setting the dataTransfer results in isTrusted being set to false for the event
Javascript DataTransfer items not persisting through async calls