encountered a business requirement at work.
implements a task queue, and then executes the next task after the previous task has been executed. I wanted to implement an asynchronous serial queue with promise. But this time the situation is different. After thinking about it for a while, I can"t figure it out. Ask the boss for advice.
the business scenario abstracts as follows:
there is the following task queue T = [A br B]
and there is already a listening function F = onStateChange (res = > "res is the value I want to judge")
An and B both install a run method (return promise), this method executes a logic that triggers a State change, and then decides whether it is resolve or reject based on the value of res
the concrete example is:
Mini Program needs to send several instructions to the Bluetooth device to connect to Bluetooth according to whether the previous instruction is passed or not before the next instruction can be carried out.