Espruino does have a main loop - as would any RTOS. The confusion is probably that the ESP8266 has its own RTOS which you then expect to call Espruino.
When Espruino isn't doing anything for a set time period it calls jshSleep, which should go to sleep for the amount of time requested, but should return early if an event happens. You should be able to hook onto that, or if you need something that returns you could modify jsiIdle to instead return the amount of time it wants to sleep for.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Espruino does have a main loop - as would any RTOS. The confusion is probably that the ESP8266 has its own RTOS which you then expect to call Espruino.
When Espruino isn't doing anything for a set time period it calls jshSleep, which should go to sleep for the amount of time requested, but should return early if an event happens. You should be able to hook onto that, or if you need something that returns you could modify jsiIdle to instead return the amount of time it wants to sleep for.