Skip to main content

Track changes to mutable data types.

Project description

Build Status Documentation Status Version Info

Spectate

A library for Python 2 and 3 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 user's 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-0.4.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

spectate-0.4.0-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spectate-0.4.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for spectate-0.4.0.tar.gz
Algorithm Hash digest
SHA256 1231db5d405d01be6e1c2c242c132b8373021081050a2f1301f7f54d072b0746
MD5 ae5a39abd4557e20e049919ed210c507
BLAKE2b-256 637b90dc334345b0fc57a93093f7e66d98bd738451b77e1a9cda7c6832aaaf4e

See more details on using hashes here.

File details

Details for the file spectate-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: spectate-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for spectate-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16e0413e7beea7a5548cf48c1be7de062ad7ea73134999f58a7d641f858dea6c
MD5 6fb1bf43ee9bfa3e9328ae86b41d6262
BLAKE2b-256 4ae9059da685b7ed1da9f1ca925c86ad5e83ca52c596b3f430aca207cd160a7c

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