Skip to main content

running effects on value updates with dependency discovery - conceptually inspired by Signal in JavaScript

Project description

Lazy Signals 🪢

GitHub GitHub Workflow Status (with event) PyPI - Python Version PyPI - Version

lazysignals is a Python library that runs effects whenever state changes. It employs dependency discovery and updates are lazy. The library is conceptually inspired by signals in JavaScript.

Please checkout our latest documentation.

Example

The framework runs relevant effects whenever some state changes:

define a new signal s, holding the initial value 1

s = Signal(1)

derive a signal that checks the parity of s

p = derived(lambda: s.value % 2 == 0)

log the parity p to the console

effect(lambda: print(f"parity:", "even" if p.value else "odd"))

perform some updates to s

s.value = 1  # no change, no output
s.value = 2  # output: "parity: even"
s.value = 3  # output: "parity: odd"
s.value = 5  # no change, no output
s.value = 6  # output: "parity: even"

Have a look at example.py for more; run with pipenv install (to locally install this library) and pipenv run example.

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

lazy_signals-0.2.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lazy_signals-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file lazy_signals-0.2.0.tar.gz.

File metadata

  • Download URL: lazy_signals-0.2.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lazy_signals-0.2.0.tar.gz
Algorithm Hash digest
SHA256 cb4cd68b1a213c209177aeebc946ffaecaf8189f3fc6f9df0d8afd0e1b253199
MD5 04b3a23f891a147b9d926ebbb037fda0
BLAKE2b-256 9f4ad43192d2d56d17caca3ed5e0c2b04d1b23bdb7078365c9899896c393f983

See more details on using hashes here.

Provenance

The following attestation bundles were made for lazy_signals-0.2.0.tar.gz:

Publisher: release.yaml on adrian-gallus/lazy-signals-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lazy_signals-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: lazy_signals-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for lazy_signals-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 93f9c6122e9e3cea7e289abeff4341661f7e61bbdfa5f1ae3890a71480bcf786
MD5 e75648858f678ae53d5583a8d45f6716
BLAKE2b-256 d21c5474033ebb42c4fc2e7315ae843cb28fbabb4d2488c5fb26fd368c23841c

See more details on using hashes here.

Provenance

The following attestation bundles were made for lazy_signals-0.2.0-py3-none-any.whl:

Publisher: release.yaml on adrian-gallus/lazy-signals-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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