marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.02k stars 796 forks source link

Chapter 11: how to run routeRequest() after all nodes received connections ? #525

Closed thelong0705 closed 4 years ago

thelong0705 commented 4 years ago

Hi, thank you for the great book! I'm having trouble running the sample code for Chapter 11.

When ever i tried to run routeRequest(bigOak, "Church Tower", "note", "Incoming jackdaws!") command it gives me Error: No route to Church Tower because the connections in bigOak haven't got updated.

Can u tell me how to run the routeRequest(bigOak, "Church Tower", "note", "Incoming jackdaws!") command right after the connections has been broadcasted to all nest ?

marijnh commented 4 years ago

There's no great way to do this, but you can use setTimeout to wait a while before your code runs.

thelong0705 commented 4 years ago

Thanks for your answer, i was trying to find a way to run it right after the connections has been broadcasted but i guess i will settle for setTimeout.