def subscribe(self,<EOL>event_type: Type[TSubscribeEvent],<EOL>handler: Callable[[TSubscribeEvent], None]) -> Subscription:
if event_type not in self._handler:<EOL><INDENT>self._handler[event_type] = []<EOL><DEDENT>casted_handler = cast(Callable[[BaseEvent], Any], handler)<EOL>self._handler[event_type].append(casted_handler)<EOL>return Subscription(lambda: self._handler[event_type].remove(casted_handler))<EOL>
Subscribe to receive updates for any event that matches the specified event type.
A handler is passed as a second argument an :class:`~lahja.misc.Subscription` is returned
to unsubscribe from the event if needed.