Skip to main content

Reactives - a small, simple, and fast framework for reactive programming

Project description

Reactives

A small, simple, and fast framework for reactive programming

Before anything else make sure you read and agree with the license.

Installation

Available through pip:

pip install jfaleiro.reactives

or poetry:

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

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.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

jfaleiro.reactives-1.0.1-py3-none-any.whl (23.1 kB view hashes)

Uploaded Python 3

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