Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

feat: add listener shortcut to event objects #611

Merged
merged 1 commit into from
Aug 20, 2022
Merged

Conversation

LordOfPolls
Copy link
Member

@LordOfPolls LordOfPolls commented Aug 18, 2022

What type of pull request is this?

  • Non-breaking code change
  • Breaking code change
  • Documentation change/addition
  • Tests change

Description

Allows you to add a listener to an event directly from the event class itself. Purely a shortcut method for nicer code.

# before
bot.add_listener(Listener.create("player_update")(self._player_state_update))

# after
PlayerUpdate.listen(self.player_state_update, bot)

Changes

  • Add listener classmethod to _BaseEvent

Checklist

  • I've formatted my code with Black
  • I've ensured my code works on Python 3.10.x
  • I've tested my code

real niche, but its useful to me!
@LordOfPolls LordOfPolls added the New Feature::Library A new feature for the library label Aug 18, 2022
@LordOfPolls LordOfPolls merged commit a0b80bd into dev Aug 20, 2022
@LordOfPolls LordOfPolls deleted the event-listeners branch August 20, 2022 07:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
New Feature::Library A new feature for the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants