I am trying to migrate an old Javascript application to use AsyncJAX (AJAX) instead of Synchronous calls to AJAX(SJAX). I have considered few approaches, each taking quite some time
1) using async/await in order to get this work i would have to prepend every function that results in calling the SJAX somewhere in the stack by "async" and every call to SJAX by "await"
2) Analyze all possible stacktraces (i do not know of any tool that can do it for JS) and do the re-write by hand using callbacks/Promisses (don't really care about cleanliness of the code right now. There is more 200 occurences of the SJAX calls in the app so i expect there might be much more possible stacktraces to handle
3) throwing an error before the actual data-fetch (SJAX call), recording the caller somewhere and repeating the call when the data is readily available (there might be other issues, imagine running the same code twice using a "stateful" variable)
4) something completely different
My question is, what approach would you think would be the best. I know this is opinion based, but maybe there is other way to handle this elegantly (point 4). If you know an answer to that ... shoot it.