def add(self, name, func):
was_empty = self._empty()<EOL>self.hooks.setdefault(name, []).append(func)<EOL>if self.app and was_empty and not self._empty(): self.app.reset()<EOL>
Attach a callback to a hook.