Add types for lifecycle events.

>Otherwise it's a really annoying if/else/else block when you are figuring out which handler to call, and adding new handlers requires extending that block.

I believe god invented functions to solve this problem :)