'Return a decorator that registers the wrapped function.'

def on(self, name):

    hook = get_hook(name)
    def hook_decorator(fn):
        if self.registered:
            hook.register_handler(fn)
        else:
            self.connections.append((hook, fn))
        return fn
    return hook_decorator
