ding.framework.event_loop¶
ding.framework.event_loop
¶
EventLoop
¶
on(event, fn)
¶
Overview
Subscribe to an event, execute this function every time the event is emitted.
Arguments:
- event (:obj:str): Event name.
- fn (:obj:Callable): The function.
off(event, fn=None)
¶
Overview
Unsubscribe an event, or a specific function in the event.
Arguments:
- event (:obj:str): Event name.
- fn (:obj:Optional[Callable]): The function.
once(event, fn)
¶
Overview
Subscribe to an event, execute this function only once when the event is emitted.
Arguments:
- event (:obj:str): Event name.
- fn (:obj:Callable): The function.
emit(event, *args, **kwargs)
¶
Overview
Emit an event, call listeners. If there is an unhandled error in this event loop, calling emit will raise an exception, which will cause the process to exit.
Arguments:
- event (:obj:str): Event name.
listened(event)
¶
Overview
Check if the event has been listened to.
Arguments:
- event (:obj:str): Event name
Returns:
- listened (:obj:bool): Whether this event has been listened to.
get_event_loop(name='default')
classmethod
¶
Overview
Get new event loop when name not exists, or return the existed instance.
Arguments:
- name (:obj:str): Name of event loop.
Full Source Code
../ding/framework/event_loop.py