running effects on value updates with dependency discovery - conceptually inspired by Signal in JavaScript
Project description
Lazy Signals 🪢
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
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 Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb4cd68b1a213c209177aeebc946ffaecaf8189f3fc6f9df0d8afd0e1b253199
|
|
| MD5 |
04b3a23f891a147b9d926ebbb037fda0
|
|
| BLAKE2b-256 |
9f4ad43192d2d56d17caca3ed5e0c2b04d1b23bdb7078365c9899896c393f983
|
Provenance
The following attestation bundles were made for lazy_signals-0.2.0.tar.gz:
Publisher:
release.yaml on adrian-gallus/lazy-signals-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lazy_signals-0.2.0.tar.gz -
Subject digest:
cb4cd68b1a213c209177aeebc946ffaecaf8189f3fc6f9df0d8afd0e1b253199 - Sigstore transparency entry: 210806375
- Sigstore integration time:
-
Permalink:
adrian-gallus/lazy-signals-python@82c92f64391e56c692b0e84d4d417c7fcbfdea89 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/adrian-gallus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@82c92f64391e56c692b0e84d4d417c7fcbfdea89 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93f9c6122e9e3cea7e289abeff4341661f7e61bbdfa5f1ae3890a71480bcf786
|
|
| MD5 |
e75648858f678ae53d5583a8d45f6716
|
|
| BLAKE2b-256 |
d21c5474033ebb42c4fc2e7315ae843cb28fbabb4d2488c5fb26fd368c23841c
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lazy_signals-0.2.0-py3-none-any.whl -
Subject digest:
93f9c6122e9e3cea7e289abeff4341661f7e61bbdfa5f1ae3890a71480bcf786 - Sigstore transparency entry: 210806389
- Sigstore integration time:
-
Permalink:
adrian-gallus/lazy-signals-python@82c92f64391e56c692b0e84d4d417c7fcbfdea89 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/adrian-gallus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@82c92f64391e56c692b0e84d4d417c7fcbfdea89 -
Trigger Event:
release
-
Statement type: