ESP32 serial interrupt

Hey guys. How can I get the serial interrupt on esp32 in arduino ide. I have a function to receive data but I want it to be immediately handled as soon as I get the data. I used serial.event() but it is working with arduino mega but not with esp32.

Your suggestions will be appreciated