Skip to content

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

Merged
da-h merged 2 commits intomasterfrom
event_exists
Nov 19, 2021
Merged

event: added method event.exists(event_name)#101
da-h merged 2 commits intomasterfrom
event_exists

Conversation

@da-h
Copy link
Copy Markdown
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