Skip to main content

Track changes to mutable data types.

Project description

Build Status Documentation Status Version Info

Spectate

A library for Python 3.6 and above that can track changes to mutable data types.

With spectate, complicated protocols for managing updates don't need to be the outward responsibility of a user and can instead be done automagically in the background. For instance, syncing the state between a server and client can controlled by spectate, so users don't have to.

Documentation

https://python-spectate.readthedocs.io/en/latest/

Install

  • stable
pip install spectate
  • pre-release
pip install spectate --pre
  • master
pip install git+https://github.com/rmorshea/spectate.git#egg=spectate
  • developer
git clone https://github.com/rmorshea/spectate && cd spectate/ && pip install -e . -r requirements.txt

At A Glance

If you're using Python 3.6 and above, create a model object

from spectate import mvc

l = mvc.List()

Register a view function to it that observes changes

@mvc.view(l)
def printer(l, events):
    for e in events:
        print(e)

Then modify your object and watch the view function react

l.append(0)
l[0] = 1
l.extend([2, 3])
{'index': 0, 'old': Undefined, 'new': 0}
{'index': 0, 'old': 0, 'new': 1}
{'index': 1, 'old': Undefined, 'new': 2}
{'index': 2, 'old': Undefined, 'new': 3}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spectate-1.0.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

spectate-1.0.0-py2.py3-none-any.whl (11.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file spectate-1.0.0.tar.gz.

File metadata

  • Download URL: spectate-1.0.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for spectate-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a7eb2d4d5c2d64cd8b9614f8590a5d1816be88f6e3572963e9f02f7c43502709
MD5 d90ba9a3465a732f7bb3d01815664e50
BLAKE2b-256 bc68f401eb9e087218d0a9c5e1b04977d09b9063c87c651f8471c568c76e3305

See more details on using hashes here.

File details

Details for the file spectate-1.0.0-py2.py3-none-any.whl.

File metadata

  • Download URL: spectate-1.0.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.2

File hashes

Hashes for spectate-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f715f7b184c94df6c8de5031ffb8f3eb5685ebad2f62bc1b11af408b3856e35e
MD5 4b1fd42de51e0c3e9b401e171c71f308
BLAKE2b-256 cc0cdafbf9508e237832c9712df144e956f9120b519743bcbdd652751fb1a35e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page