Metadata-Version: 2.1
Name: jfaleiro.reactives
Version: 1.0.1
Summary: Reactives - a small, simple, and fast framework for reactive programming
Home-page: https://gitlab.com/jfaleiro.open/reactives
License: AGPL-3.0-or-later
Author: J Faleiro
Author-email: j@falei.ro
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Provides-Extra: coverage
Provides-Extra: interactive-dev
Provides-Extra: tests
Requires-Dist: autopep8 (>=1.5.5,<2.0.0); extra == "interactive-dev"
Requires-Dist: coverage (>=5.4,<6.0); extra == "coverage"
Requires-Dist: flake8 (>=3.8.4,<4.0.0); extra == "interactive-dev"
Requires-Dist: isort (>=5.7.0,<6.0.0); extra == "interactive-dev"
Requires-Dist: networkx (>=2.5,<3.0)
Requires-Dist: pre-commit (>=2.10.1,<3.0.0); extra == "interactive-dev"
Requires-Dist: pylint (>=2.7.0,<3.0.0)
Requires-Dist: pytest (>=6.2.2,<7.0.0); extra == "tests" or extra == "coverage"
Requires-Dist: rope (>=0.18.0,<0.19.0); extra == "interactive-dev"
Requires-Dist: uvloop (>=0.15.2,<0.16.0)
Description-Content-Type: text/markdown

# Reactives

A small, simple, and fast framework for reactive programming

Before anything else make sure you read and agree with the [license](LICENSE.txt).

## Installation

Available through `pip`:

```bash
pip install jfaleiro.reactives
```

or `poetry`:

```bash
poetry add jfaleiro.reactives
```

## Use

Reactives allow for three types of bindings: `pre`, `post`, and `notify`.

* `pre` bindings - a chain of calls executed synchronously and in sequence before an update on state is performed. For `R` reactives, the value of the last execution on pre-binding chain is kept. Special shortcuts:

  * `guard` - used to establish boolean conditions for a change in state to fail.

* `post` bindings - a chain of calls executed synchronously and in sequence after an update on state is performed. For synchronous notification purposes. Exceptions and updates are ignored.

* `notify` bindings - a chain of calls executed asynchronously and after the last `post` call is performed. For asynchronous notification purposes. Exceptions and updates are ignored

```python
with Context() as x:
    a = x.new(R, 1)
    b = x.new(R, 2)
    c = a + b

    assert a.value == 1
    assert b.value == 2
    assert c.value == 3

    a.pre(guard(lambda x: x > 0))
    c.pre(guard(lambda x: x >= 3))

    a.value = 4

    assert a.value == 4
    assert b.value == 2
    assert c.value == 6

```

## To Know More

Look for plenty of examples of use under `./tests` as well as Jupyter notebooks on `./samples` for interactive use.

Enjoy.

