All Projects → YarikTH → ureact

YarikTH / ureact

Licence: BSL-1.0 license
Minimalistic reactive library for c++

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
shell
77523 projects
Makefile
30231 projects

Projects that are alternatives of or similar to ureact

Beicon
Reactive Streams for ClojureScript
Stars: ✭ 133 (+9.02%)
Mutual labels:  reactive, reactive-programming
Awesome Reactive Programming
A repository for sharing all the resources available on Reactive Programming and Reactive Systems
Stars: ✭ 163 (+33.61%)
Mutual labels:  reactive, reactive-programming
Redux Most
Most.js based middleware for Redux. Handle async actions with monadic streams & reactive programming.
Stars: ✭ 137 (+12.3%)
Mutual labels:  reactive, reactive-programming
Rsocket Rpc Java
Standard RSocket RPC Java Implementation
Stars: ✭ 126 (+3.28%)
Mutual labels:  reactive, reactive-programming
servable
"simple" observable implementation based off RxJS & kefir Docs
Stars: ✭ 14 (-88.52%)
Mutual labels:  reactive, reactive-programming
Ayanami
🍭 A better way to react with state
Stars: ✭ 129 (+5.74%)
Mutual labels:  reactive, reactive-programming
Reactive Ms Example
An educational project to learn reactive programming with Spring 5
Stars: ✭ 157 (+28.69%)
Mutual labels:  reactive, reactive-programming
Rxswift To Combine Cheatsheet
RxSwift to Apple’s Combine Cheat Sheet
Stars: ✭ 1,040 (+752.46%)
Mutual labels:  reactive, reactive-programming
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (-66.39%)
Mutual labels:  reactive, reactive-programming
netifi-quickstart-java
Project to assist you in getting started using Netifi.
Stars: ✭ 23 (-81.15%)
Mutual labels:  reactive, reactive-programming
Lda Topic Modeling
A PureScript, browser-based implementation of LDA topic modeling.
Stars: ✭ 91 (-25.41%)
Mutual labels:  reactive, reactive-programming
KotlinReactiveMS
An educational project to learn reactive programming with Spring 5 and Kotlin
Stars: ✭ 33 (-72.95%)
Mutual labels:  reactive, reactive-programming
Bulb
A reactive programming library for JavaScript.
Stars: ✭ 84 (-31.15%)
Mutual labels:  reactive, reactive-programming
Combine Mvvm
Sample project with Combine & UIKit framework, MVVM architecture
Stars: ✭ 132 (+8.2%)
Mutual labels:  reactive, reactive-programming
Rocket.jl
Functional reactive programming extensions library for Julia
Stars: ✭ 69 (-43.44%)
Mutual labels:  reactive, reactive-programming
Combineexamples
Getting started with Apple Combine
Stars: ✭ 145 (+18.85%)
Mutual labels:  reactive, reactive-programming
Rxdownloader
- Reactive Extension Library for Android to download files
Stars: ✭ 40 (-67.21%)
Mutual labels:  reactive, reactive-programming
Inferno Most Fp Demo
A demo for the ReactJS Tampa Bay meetup showing how to build a React+Redux-like architecture from scratch using Inferno, Most.js, reactive programmning, and various functional programming tools & techniques
Stars: ✭ 45 (-63.11%)
Mutual labels:  reactive, reactive-programming
Fpgo
Monad, Functional Programming features for Golang
Stars: ✭ 165 (+35.25%)
Mutual labels:  reactive, reactive-programming
sample-spring-reactive
sample reactive microservices using spring 5, spring boot, spring webflux and project reactor
Stars: ✭ 26 (-78.69%)
Mutual labels:  reactive, reactive-programming

µReact

Ubuntu Windows MacOS CodeQL Codacy Badge Language grade: C/C++

Standard Type GitHub license download Docs GitHub Releases GitHub Issues PRs Welcome

µReact is an open-source minimalistic single-header 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.

Documentation

Features

  • 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 - see the tutorial
  • 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

Examples

Basic usage (run)

ureact::context ctx;

// Declaring reactive variables. We can reassign their values later
ureact::value<int> b = ctx.make_value(1);
ureact::value<int> c = ctx.make_value(2);

// Declaring reactive function using overloaded operator
// Its value will be updated each time its dependencies are changed
ureact::function<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

Complex signals (run)

ureact::context ctx;

ureact::value<int> base = ctx.make_value(1);
ureact::value<int> exp  = ctx.make_value(3);

// Declaring reactive function with formula
// Its value will be recalculated according to the given function
ureact::function<double> result = make_function( with(base, exp) , std::pow<int, int> );

// Alternative form of make_function using operator |
ureact::function<std::string> expression = with(base, exp, result) |
    []( int base, int exp, int result ){
        return std::to_string(base) + "^" + std::to_string(exp)
            + " == " + std::to_string(result);
    };

std::cout << expression.get() << "\n"; // 1^3 == 1

base <<= 2;
std::cout << expression.get() << "\n"; // 2^3 == 8

exp <<= 0;
std::cout << expression.get() << "\n"; // 2^0 == 1

Observers (run)

ureact::context ctx;

ureact::value<int> a = ctx.make_value(1);
ureact::function<int> abs_a = with(a) | [](int a){ return std::abs(a); };
ureact::function<int> abs_a_x2 = abs_a * 2;

// Declaring reactive observers
// They execute given functor only when the observed value is changed
observe(a,        []( int a ){        std::cout << "  a -> "        << a << "\n"; });
observe(abs_a,    []( int abs_a ){    std::cout << "  abs(a) -> "    << abs_a << "\n"; });
observe(abs_a_x2, []( int abs_a_x2 ){ std::cout << "  abs(a)*2 -> " << abs_a_x2 << "\n"; });

// All values change their values so all of them is notified
std::cout << "a <<= 3\n";
a <<= 3;

// Only change of 'a' is notified
// Value of 'abs_a' is not changed after recalculation, so it is not notified
// Value 'abs_a_x2' is not even recalculated because the value of 'abs_a' is not changed
std::cout << "a <<= -3\n";
a <<= -3;

Output:

a <<= 3
  a -> 3
  abs(a) -> 3
  abs(a)*2 -> 6
a <<= -3
  a -> -3

Transaction (run)

ureact::context ctx;

ureact::value<int> b = ctx.make_value(1);
ureact::value<int> c = ctx.make_value(1);
ureact::function<int> a = b + c;

observe(a, []( int a ){ std::cout << "  a -> " << a << "\n"; });

// Normally values are recalculated each change of their dependencies
std::cout << "without transaction\n";
std::cout << "b <<= 2\n";
b <<= 2;
std::cout << "c <<= 2\n";
c <<= 2;

// To perform several changes atomically they should be grouped into a transaction
std::cout << "\nwith transaction\n";
ctx.do_transaction([&]()
{
    std::cout << "b <<= 3\n";
    b <<= 3;
    std::cout << "c <<= 3\n";
    c <<= 3;
});

Output:

without transaction
b <<= 2
  a -> 3
c <<= 2
  a -> 4

with transaction
b <<= 3
c <<= 3
  a -> 6

See other examples at the examples folder.

License

This software is licensed under the Boost Software License 1.0:

Copyright © 2014-2017 Sebastian Jeckel

Copyright © 2020-2021 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.

Used third-party tools

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!

Contact

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].