def on(self, signal, callback=None, max_calls=None):
        """
        Registers a single callback for receiving an event. Optionally, can specify a maximum number 
        of times the callback should receive a signal. This method works as both a function and a decorator.
        """
        
        self._check_signal_is_registered(signal)

        if callback is None:
            # decorator
            def decorator(callback):
                self.on(signal, callback, max_calls=max_calls)
                
            return decorator
        else:
            return self._signal_registry[signal].on(callback, max_calls=max_calls)

        Registers a single callback for receiving an event. Optionally, can specify a maximum number 
        of times the callback should receive a signal. This method works as both a function and a decorator.
        
recipes/Python/580764_Simple_signal_library_similar_PyQT/recipe-580764.py