f4exb / sdrangel

SDR Rx/Tx software for Airspy, Airspy HF+, BladeRF, HackRF, LimeSDR, PlutoSDR, RTL-SDR, SDRplay and FunCube
GNU General Public License v3.0
2.72k stars 420 forks source link

Make all REST API requests sync? #2131

Open sandric opened 4 weeks ago

sandric commented 4 weeks ago

I was playing with rest api creating frequency scanner similar to scanner.py but in nodejs. The thing I noticed is that I constantly need to struggle with adding delays after api call to change device or channel settings. It is easily noticeable on start or stop api call on device - its a bit computationally heavy task so its always returns opposite state of a device. I was wondering whats the best way to overcome this since I do not know exactly how long should I wait till say I start querying report on a channel for a device that is still starting, although api call already finished. Right not its just dumb delays, but maybe there's a better more elegant way? Maybe listen to reverse api request for every api call I make as a "finish" signal? This way code becomes quite a bit more complex, would be cool to have simple "sync" flag to return answer only when task completely done..

f4exb commented 4 weeks ago

A REST API is essentially asynchronous.