diff --git a/src/tqdm_publisher/_progress_subscriber.py b/src/tqdm_publisher/_progress_subscriber.py new file mode 100644 index 0000000..b892f4e --- /dev/null +++ b/src/tqdm_publisher/_progress_subscriber.py @@ -0,0 +1,14 @@ +from ._publisher import TQDMPublisher + + +class TQDMProgressSubscriber(TQDMPublisher): + def __init__(self, iterable, *, announcer: "?", request_id: str, message: dict, **tqdm_kwargs): + super().__init__(iterable, **tqdm_kwargs) + + def on_progress_update(format_dict) -> None: + """ + Describe what this announcer is all about... + """ + announcer.announce(dict(request_id=request_id, **message)) + + self.subscribe(callback=on_progress_update) diff --git a/src/tqdm_publisher/_subscriber.py b/src/tqdm_publisher/_subscriber.py deleted file mode 100644 index 289d3d6..0000000 --- a/src/tqdm_publisher/_subscriber.py +++ /dev/null @@ -1,7 +0,0 @@ -from ._publisher import TQDMPublisher - - -class TQDMProgressSubscriber(TQDMPublisher): - def __init__(self, iterable, on_progress_update: callable, **tqdm_kwargs): - super().__init__(iterable, **tqdm_kwargs) - self.subscribe(lambda format_dict: on_progress_update(dict(progress_bar_id=self.id, format_dict=format_dict)))