code: def on_publish(self):
          # type: () -> Callable
          
          def decorator(handler):
              # type: (Callable) -> Callable
              self.client.on_publish = handler
              return handler
  
          return decorator
docs: Decorator.
  
          Decorator to handle all messages that have been published by the
          client.
  
          **Example Usage:**::
  
              @mqtt.on_publish()
              def handle_publish(client, userdata, mid):
                  print('Published message with mid {}.'
                        .format(mid))