µReact is an open-source header-only functional reactive programming library for C++17.
❗️ This library is a work-in-progress. It should not be considered release quality yet and its API might still change.
However, it works perfectly fine and can be already used with small future changes in mind.
Feedback is strongly required and appreciated to stabilize the API and achieve the first major release.
- Update minimality: nothing is re-calculated or processed unnecessarily
- Glitch freedom: no transiently inconsistent data sets
- Externally synchronized (not thread-safe) by design: it allows not to pay for what you don't use and to have very determined consistent behaviour
- Ease of use: small self-contained single header code base, no external dependencies, permissive Boost Software License license
- Really easy to get started: it's just 1 header file
- Reliability: the library has an extensive set of tests
- Portability: continuously tested under Windows, MacOS and Ubuntu using MSVC/GCC/Clang
- Clean warning-free codebase even on the most aggressive warning levels for MSVC/GCC/Clang
- Doesn't pollute the global namespace (everything is in namespace
ureact
) and doesn't drag any headers with it
Basic usage (run)
#include <ureact/signal.hpp>
#include <ureact/adaptor/lift.hpp>
#include <iostream>
int main() {
ureact::context ctx;
// Declaring reactive variables. We can reassign their values later
ureact::var_signal<int> b = make_var( ctx, 1 );
ureact::var_signal<int> c = make_var( ctx, 2 );
// Defining reactive signal using overloaded operator
// Its value will be updated each time its dependencies are changed
ureact::signal<int> a = b + c;
std::cout << "a (init): " << a.get() << "\n"; // 3
// Assign a new value to 'b'. Value of 'a' is recalculated automatically
b <<= 10;
std::cout << "a (new): " << a.get() << "\n"; // 12
}
This software is licensed under the Boost Software License 1.0:
Copyright © 2014-2017 Sebastian Jeckel
Copyright © 2020-2023 Krylov Yaroslav
Permission is hereby granted, free of charge, to any person or organization obtaining a copy of the software and accompanying documentation covered by this license (the "Software") to use, reproduce, display, distribute, execute, and transmit the Software, and to prepare derivative works of the Software, and to permit third-parties to whom the Software is furnished to do so, all subject to the following:
The copyright notices in the Software and this entire statement, including the above license grant, this restriction and the following disclaimer, must be included in all copies of the Software, in whole or in part, and all derivative works of the Software, unless such copies or derivative works are solely in the form of machine-executable object code generated by a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This software started out as a fork of the cpp.react by Sebastian Jeckel ([email protected]), BSL 1.0 licensed.
The library itself consists of a single header file licensed under the Boost Software License license. However, it is built, tested, documented, and whatnot using a lot of third-party tools and services. Thanks a lot!
- CMake for build automation
- ClangFormat for automatic source code indentation
- gersemi for automatic CMake code indentation
- Cache2 for the unit tests
- nanobench for the benchmarks
- codecov.io for monitoring test coverage
If you have questions regarding the library, I would like to invite you to open an issue at GitHub. Please describe your request, problem, or question as detailed as possible, and also mention the version of the library you are using as well as the version of your compiler and operating system. Opening an issue at GitHub allows other users and contributors to this library to collaborate.