A simple Observer Pattern implementation with decorators
Project description
peepy
A simple Observer Pattern implementation with decorators
Installation
Simply instasll from pypi:
pip3 install peepy
Usage
Observables can be connected to bserver callbacks siply by callling the bind_to method or by using the observe, observe_dict and observer_function decorators
from peepy.Observables import Observable, ObservableDict, observe, observe_dict
foo = Observable('important object')
foo2 = Observable('important object 2')
@observe(foo, foo2)
def observer(label, old, new):
print('Changing {0}\'s value from {1} to {2}'.format(label, old, new))
foo.value = 'bar'
foo.value = 'baz'
foo2.value = foo
foo_dict = ObservableDict({'foo': 1, 'bar':{}})
@foo_dict.observer_function
def dict_observer(label, old, new):
print('Changing key {0} from {1} to {2}'.format(label, old, new))
foo_dict['foo'] = 2
foo_dict['foo2'] = 20
foo_dict['bar'] = {'baz':None}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
peepy-0.0.2-py3-none-any.whl
(3.0 kB
view details)
File details
Details for the file peepy-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: peepy-0.0.2-py3-none-any.whl
- Upload date:
- Size: 3.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef330da3c830c7b43ccdcb370d01d18805f77e34d6d82323fb730a8496332523 |
|
MD5 | fa0910776472823e432692a8f24b16e3 |
|
BLAKE2b-256 | 40ee597cd5955ce4fbbe3a2ae26b3c3c7446fd71d568636399306e8f5a41b3a7 |