code: def add_listener(self, event, callback, single=False, priority=1):
          
          event_stack = self._events[event]
          event_stack.append({
              "callback": callback,
              "single": single,
              "priority": priority
          })
          event_stack.sort(key=lambda x: x['priority'])
docs: Add a callback to an event list so it will be run at this event's
          firing. If single is True, the event is auto-removed after the first
          invocation. Priority can be used to jump ahead or behind other
          callback invocations.