Skip to content

Releases: YarikTH/ureact

0.8.0

29 Jan 01:13
f2a4c88
Compare
Choose a tag to compare

Full Changelog

Great headers rework

  • BREAKING! "include/ureact/ureact.hpp" is separated into several more
    specialized headers.
    Unlike 0.7.0, ureact.hpp is completely replaced with the new headers.
    More fractional includes allow to reduce inclusion cost.
    All headers are guarantied to be self-contained.
    Use textual search to search wanted functionality because code reference is
    not made yet.
  • BREAKING! constructors of var_signal and event_source that allow
    non-default construction
    without make_var and make_source are removed
  • add function object version of var_signal<S>::set().
    It allows to mimic not only getter functions, but also setter functions.
struct A
{
    void foo(const int& newValue);
    [[nodiscard]] int foo() const;

    var_signal<int> bar;
};

int main()
{
    A test;
    test.foo(42);
    std::cout << test.foo() << "\n";

    test.bar(42);
    std::cout << test.bar() << "\n";
}
  • add sanity checks for functions passed in non-observer algorithms such as
    lift, process and fold.
    This check works only if NDEBUG is not defined and prevents common misuses:
    • creation of nodes from callback (make_XXX and algorithms producing new
      signal/events/observer)
    • read/setting/modification of signal value from callback
    • emitting event from callback
  • add transaction class that is RAII version of do_transaction()
  • add member_XXX classes that restrict reassignment only for Owner class.
    Base idea was taken
    from https://danieldinu.com/observable/getting-started.html#getting-started-with-observable-properties
    member_signal<Owner, S>, member_var_signal<Owner, S>,
    member_events<Owner, E> and member_event_source<Owner, E> are added.
    Interfaces member_events_user, member_signal_user and
    macro UREACT_USE_MEMBER_SIGNALS, UREACT_USE_MEMBER_EVENTS are added to
    make usage easier.
  • add sink algorithm that allows to assign value to reactive value in complex expressions
ureact::context ctx;

ureact::var_signal<int> src = make_var( ctx, 1 );
ureact::signal<int> squared;
ureact::signal<int> minus_squared;
static const auto square = []( auto i ) { return i * i; };

std::ignore =                                  // TODO: remove it once nodiscard done right
    src                                        //
    | ureact::lift( square ) | sink( squared ) //
    | ureact::lift( std::negate<>{} ) | sink( minus_squared );

assert( squared.get() == 1 );
assert( minus_squared.get() == -1 );

src <<= -2;

assert( squared.get() == 4 );
assert( minus_squared.get() == -4 );
  • add fork algorithm that allows to express multiple transformation of the same source
ureact::context ctx;

auto src = ureact::make_source<int>( ctx );
static const auto negate = []( auto i ) { return -i; };
static const auto x2 = []( auto i ) { return i * 2; };
static const auto square = []( auto i ) { return i * i; };

ureact::events<int> dst1;
ureact::events<int> dst2;
ureact::events<int> dst;

// makes void lambda to check if fork supports it
auto make_transform_to = []( auto func, ureact::events<int>& where ) {
    return [func, &where]( const auto& src ) { //
        std::ignore =                          // TODO: remove it once nodiscard done right
            src | ureact::transform( func ) | ureact::sink( where );
    };
};

dst =                                                       //
    src                                                     //
    | ureact::fork(                                         //
        ureact::transform( negate ) | ureact::sink( dst1 ), //
        make_transform_to( x2, dst2 )                       //
        )
    | ureact::transform( square );

const auto negate_result = ureact::collect<std::vector>( dst1 );
const auto x2_result = ureact::collect<std::vector>( dst2 );
const auto square_result = ureact::collect<std::vector>( dst );

for( int i = 1; i < 4; ++i )
    src << i;

assert( negate_result.get() == std::vector<int>{ -1, -2, -3 } );
assert( x2_result.get() == std::vector<int>{ 2, 4, 6 } );
assert( square_result.get() == std::vector<int>{ 1, 4, 9 } );

0.7.0

27 Nov 13:07
1abb6a1
Compare
Choose a tag to compare

Great headers rework. µReact is not longer single-header library

  • "include/ureact/ureact.hpp" is separated into several more specialized headers.
    "single_include/ureact/ureact_amalgamated.hpp" contains all the headers content,
    but has no CMake target. Its main purpose is to be used in godbolt snippets.
  • std::invoke() is used instead of functional call in most of the places receiving
    func or predicate, so member access and member function calls can be performed.
struct User
{
    int age;
    int get_age(){ return age; }
};

ureact::context ctx;
auto user = make_var( ctx, User{18});
auto user_age = lift( user, &User::age );
assert( user_age.get() == 18 );
auto user_age_2 = lift( user, &User::get_age );
assert( user_age_2.get() == 18 );
  • ureact::lift() overloads have optional first template parameter to select
    desired type of resulting signal
  • default signal type deduction for ureact::lift() removes references from
    the invoke result type
  • ureact::reactive_ptr() and ureact::reactive_ref() are merged into new
    ureact::reactive_ref() that works as both
  • curried version of ureact::flatten() is added
  • unary version of ureact::lift() is optimized to steal op from temp_signal<S>&&
    sources like unary signal operators did.
    unary signal operators are reworked to call unary ureact::lift() with standard
    unary functors when it is possible (std::negate<> and others)
  • binary version of ureact::lift() is added in form ureact::lift(lhs, op, rhs).
    It is optimized to steal op from temp_signal<S>&& sources like binary signal
    operators did.
    binary signal operators are reworked to call binary ureact::lift() with standard
    binary functors when it is possible (std::plus<> and others)
  • -Wimplicit-int-float-conversion suppression is removed from lift code
  • additional sanity assert in temp_signal::steal_op() is added
  • curried version of ureact::observe() is added
  • new ureact::tap() algorithm is added. It works like ureact::observe(),
    but returns received source instead of observer

see the full changelog

0.6.0

18 Aug 02:07
da3c91a
Compare
Choose a tag to compare

Great library rework. There are a lot of changes that would be documented and cleaned up later

  • Port events code from cpp.react
  • Introduce lots of breaking changes:
    • revert renaming var_signal->value, signal->function, make_var->make_value
    • rename make_signal/make_function to lift
    • replace operator| overload for signals and function with operator| overload on signals and partially applied lift function
    • convert context::do_transaction() to free function
    • remove context::make_value() use free function make_var() instead
    • remove comma operator overload for signal packs. Use free function with() instead
    • remove reference overloads for signal and var_signal. Use std::reference<S> version instead

see the full changelog

download the header from here

0.5.0

29 Aug 18:06
Compare
Choose a tag to compare

The main change is the dropping of c++11 and c++14 support. Now library is c++17

  • Make observe method nodiscard, but for rvalue only #93
  • Change version number form #92
  • Raise c++ standard to c++17 #90

see the full changelog

download the header from here

0.4.0

22 Aug 18:10
0daf7eb
Compare
Choose a tag to compare

Interface reorganization. One big breaking change. See changelog to find out how to adapt your code

see the full changelog

download the header from here

0.3.0

15 Aug 11:50
Compare
Choose a tag to compare

Pack of minor interface changes

  • Use gitlab-changelog-generator #43

  • Convert operator| to return detail::temp_signal<S, op_t> #81

  • Remove returned value from var_signal::operator<<= #79

  • Remove signal<S>::flatten() method #77

  • Replace operator->* with operator| to make signals #74

  • Remove bitwise operators overloads for signals #72

  • Add -stdlib=libc++ configuration for clang builds #50

  • Use sanitizers build #42

  • Convert operator| to return detail::temp_signal<S, op_t> #82 (YarikTH)

  • Remove returned value from var_signal::operator<<= #80 (YarikTH)

  • Remove signal<S>::flatten() method #78 (YarikTH)

  • Replace operator->* with operator| to make signals #75 (YarikTH)

  • CI: add sanitizers and valgrind-memcheck build configs #70 (alexezeder)

  • #50 -stdlib=libc++ configuration is added for clang builds #69 (YarikTH)

  • Add a code reference #56

  • Remove bitwise operators overloads for signals #73 (YarikTH)

  • Add code reference into documentation #76 (YarikTH)

see the full changelog

download the header from here

0.2.0

26 Jun 18:39
f240f3d
Compare
Choose a tag to compare

Pack of various improvements.

  • Add [[nodiscard]] attribute to prevent misuse of the library #34
  • Add test to check if minimal version CMake can process CMake scripts without errors #40
  • Test integration ways described in integration.md and fix them #37
  • Potential license issue #36

see the full changelog

download the header from here

0.1.0

18 Jun 13:39
37d4fbe
Compare
Choose a tag to compare

Initial release

see the full changelog

download the header from here