mirror of
https://github.com/meshtastic/python.git
synced 2025-12-28 10:27:54 -05:00
minor cleanup on observable
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
"""A basic implementation of the observer pattern."""
|
||||
|
||||
|
||||
class Event(object):
|
||||
class Event:
|
||||
"""A simple event class."""
|
||||
|
||||
class Observable(object):
|
||||
def __init__(self, source) -> None:
|
||||
self.source = source
|
||||
|
||||
class Observable:
|
||||
"""A class that represents an observable object.
|
||||
|
||||
To publish an event call fire(type="progress", percent=50) or whatever. It will call
|
||||
@@ -27,9 +30,8 @@ class Observable(object):
|
||||
Args:
|
||||
**attrs: Arbitrary keyword arguments to be passed to the callback functions.
|
||||
"""
|
||||
e = Event()
|
||||
e.source = self
|
||||
e = Event(self)
|
||||
for k, v in attrs.items():
|
||||
setattr(e, k, v)
|
||||
for fn in self.callbacks:
|
||||
fn(e)
|
||||
fn(e)
|
||||
|
||||
Reference in New Issue
Block a user