leopard
leopard copied to clipboard
Should fireTrigger return a generator function?
Right now, fireTrigger
and Trigger.start
return Promise
s. broadcastAndWait
works by waiting for the Promise
returned by fireTrigger
to resolve, and yield
ing 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).
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.