A CustomEvent
is an Element that gives App users the ability to execute a process that is independent of the Step it’s used in. This is useful for situations in which you would want to provide users with the option to:
- Take action on insights in an App (e.g. order new parts for maintenance)
- Kick-off any kind of action that isn’t automatically executed in a given Step
- Open App data in Virtualitics Explore for more in-depth analysis
Creating Custom Events
A CustomEvent
is created similarly to a Step. You must create a class for your event that is a child of the CustomEvent class and then create a callback function that utilizes flow_metadata
and defines what is to be executed.
from virtualitics_sdk import CustomEvent
class MyEvent(CustomEvent):
def callback(self, flow_metadata):
print(f"Running MyEvent")
# Place what you want to execute here
return 'Executed MyEvent Custom Event'
Once your CustomEvent
class is created, it can be instantiated in a Step and used the same as any other Element.
my_event = MyEvent(title="Event Title", description="Event Description")
event_card = Card(title="Event Card", content=[my_event])
page.add_card_to_section(card=event_card, section_title="Event Section")