Skip to content

Manager

flowtask.events.manager

EventManager

EventManager(name=None)

Basic Event Manager of flowtask.

This manager allows for dynamic loading and dispatching events based on a provided payload. Each event can have multiple actions, and actions can be loaded dynamically from modules.

Event

Event(functions, event_name)

LoadEvents

LoadEvents(event_payload=None)

Load all events and their associated actions based on the provided payload.

The payload should be a dictionary where each key is an event name and the associated value is a list of action dictionaries. Each action dictionary should have a single key (the action name) and a value that is a dictionary of parameters for that action.

Example payload: { "completed": [ { "Dummy": { "message": "Finished" } } ], ... }

Parameters:

Name Type Description Default
event_payload dict

The event payload dictionary.

None

Raises:

Type Description
RuntimeError

If there's an error loading an action.

addEvent classmethod

addEvent(**kwargs)

addEvent( event1 = [f1,f2,...], event2 = [g1,g2,...], ... ) creates events using **kwargs to create any number of events. Each event recieves a list of functions, where every function in the list recieves the same parameters. Example: def hello(): print("Hello ") def world(): print("World")

EventManager.addEvent( salute = [hello] ) EventManager.salute += world

EventManager.salute()

Output: Hello World