you can use interrupts for sure.
But as you would not do access your harddisk in an interrupt handler some restrictions apply here, too.
Make a shared data structure that is used to exchange data between interrupt code and main loop.
The typical uart drivers use that for reading serial data for example.
The nodemcu firmware provides a lua environment. Lua code can't called from interrupt ASAIK. But the driver part of the firmware makes use of interrupts for timers, uart, pwm etc. Shared data structures allow to decouple that.
Cal