move event handler into api

[#84527846]