mirror of
https://github.com/beak-insights/felicity-lims.git
synced 2025-02-23 00:12:54 +08:00
18 lines
372 B
Python
18 lines
372 B
Python
from typing import Callable
|
|
|
|
subscribers = dict()
|
|
|
|
|
|
def subscribe(event_type: str, fn: Callable):
|
|
if event_type not in subscribers:
|
|
subscribers[event_type] = []
|
|
|
|
subscribers[event_type].append(fn)
|
|
|
|
|
|
def post_event(event_type: str, **kwargs):
|
|
if event_type not in subscribers:
|
|
return
|
|
|
|
for fn in subscribers[event_type]:
|
|
fn(**kwargs)
|