Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed Sep 17, 2023
1 parent 79746fc commit 5717fb7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nicegui/observables.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ def __init__(self, data: set = set(), on_change: Callable = None) -> None:
super().__init__(data)
for item in self:
super().add(make_observable(item, on_change))
self._on_change_handler: list[Callable] = []
self._change_handlers: List[Callable] = []
if on_change is not None:
self._on_change_handler.append(on_change)
self._change_handlers.append(on_change)

def _notify_change(self) -> None:
for handler in self._on_change_handler:
for handler in self._change_handlers:
events.handle_event(handler, events.ObservableChangeEventArguments(sender=self))

def on_change(self, handler: Callable) -> None:
self._on_change_handler.append(handler)
self._change_handlers.append(handler)

def add(self, item: Any) -> None:
super().add(make_observable(item, self._notify_change))
Expand Down

0 comments on commit 5717fb7

Please sign in to comment.