You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Port of Sodium - Functional Reactive Programming (FRP) library - to Python.
Installation
Just pip install sodiumfrp.
Main Concepts
Streams and Cells
This library is based on two types:
Stream
and Cell.
Stream represents a stream of events, while Cell represents a value that changes over time.
Operators
There is also a bunch of primitives that you can use to build streams/cells and to compose them together.
They provide means for doing common operations like mapping, filtering, reduction, flat-mapping and more.
All of them are implemented as members of
Stream
and Cell classes.
Forward references
In situations, where a stream or cell needs to be referenced before it is assigned, use
StreamLoop or
CellLoop.
Interfacing with imperative world
Stream and Cell lets you model your business logic in a purely functional way.
In order to provide your model with input data, use
StreamSink and
CellSink.
And, whenever you need to get data out of the model, use
Stream.listen()
and Cell.listen().
When an input value is pushed into a stream or cell, Sodium automatically starts a transaction.
Any state changes, that occur as a result of that input, are performed within the same transaction.
Most of the time you don't need to do anything, but it is possible to start a transaction explicitly via
Transaction.run().
For example:
It often makes sense for all the program initialization to be wrapped in a single, big transaction.
StreamLoop and CellLoop require an explicit transaction.