leopard icon indicating copy to clipboard operation
leopard copied to clipboard

Should fireTrigger return a generator function?

Open adroitwhiz opened this issue 2 years ago • 1 comments

Right now, fireTrigger and Trigger.start return Promises. broadcastAndWait works by waiting for the Promise returned by fireTrigger to resolve, and yielding until then.

Async code has some really convoluted timing details, so it may be worth changing fireTrigger to return a generator function which waits until all started threads are done (or to just return the list of all started threads, and let broadcastAndWait do the waiting itself).

This may also be necessary to get some of Scratch's timing details correct (see also https://github.com/LLK/scratch-vm/pull/1683).

adroitwhiz avatar Jul 24 '22 15:07 adroitwhiz

I'm in favor of this! Generally, I think we should avoid mixing promises and generators, and I also feel like generators offer better (or easier to understand/predict) control over timing than promises. But the big thing is being consistent and preferring to use one system instead of two in general.

towerofnix avatar Jul 24 '22 22:07 towerofnix