I've been trying to understand how Mike Bostock's queue.js works, but I can't see how it manages to work. The part I don't understand is how the code manages to continue executing callbacks. In particular, I am unsure about the pop()
method (line 45). From my understanding, the method takes the next unprocessed, deferred function; appends a callback that (potentially) starts the next deferred function in the queue and executes when the immediately popped function finishes; then finally executes said function. My question is: what code executes this callback?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
Each deferred function does not actually return anything -- they are expected to execute their final argument as a callback. For example, this will not work
However, if we modify
foo
to take a callback,Then it will, as executing the callback causes
queue
to continue.If I understand the code correctly,
queue.await()
andqueue.awaitall()
put the callback in theawait
instance variable, and then this is executed bynotify()
.