Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event: added method event.exists(event_name) #101

Merged
merged 2 commits into from
Nov 19, 2021
Merged

event: added method event.exists(event_name) #101

merged 2 commits into from
Nov 19, 2021

Conversation

da-h
Copy link
Owner

@da-h da-h commented Nov 19, 2021

event.exists(event_name)

Attention: Using the event with the name exists is not possible anymore with this MR.

This MR adds the function event.exists(event_name) to each event object.

Description

Instead of calling event.optional.event_name one might want to check if an event exists and proceed from there with different behavior.

Check all before creating this PR:

  • Documentation adapted
  • unit tests adapted / created

Example Usage

It can be used inside events as follows:

def some_event(event):
   if event.exists("other_event"):
       print("other_event exists")

This can be also used for a more dynamic registration:

def register(mf):
   if mf.event.exists("some_event"):
      mf.register_event("some_event", lambda x: print("some_event called"))

@da-h da-h merged commit 749b832 into master Nov 19, 2021
github-actions bot pushed a commit that referenced this pull request Nov 19, 2021
event: added method event.exists(event_name)
@sbrodehl sbrodehl deleted the event_exists branch October 7, 2022 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant