From f3a2f8284e71b289542bffca685bee3960dce3ac Mon Sep 17 00:00:00 2001 From: Krylov Yaroslav Date: Sun, 12 Feb 2023 20:17:56 +0300 Subject: [PATCH] version 0.9.0 --- CHANGELOG.md | 70 ++++++++++++++++++++ doc/signals_vs_callbacks.md | 20 +++--- include/ureact/version.hpp | 2 +- single_include/ureact/ureact_amalgamated.hpp | 6 +- 4 files changed, 83 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1cb1606..a615fb82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,76 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [0.9.0](https://github.com/YarikTH/ureact/releases/tag/0.9.0) (2023-02-12) + +[Full Changelog](https://github.com/YarikTH/ureact/compare/0.8.1...0.9.0) + +Great closure/adaptor rework + +- BREAKING! `sink` and `fork` introduced in 0.8.0 are removed because they don't + fit into the library and lead to a lot of complicated logic to support them +- BREAKING! ureact::closure is renamed and moved in ureact::detail namespace + library is not ready for such extension point yet +- BREAKING! free functions that create new reactives (signals/events/observes) + from existing ones also called "algorithms" are replaced with inline constexpr + instances of special functor-like classes inherited from Adaptor or AdaptorClosure. + This is the same approach as used in std::ranges and range-v3. + There are some differences in usage compared with free functions: + - [Argument-dependent lookup](https://en.cppreference.com/w/cpp/language/adl) + is not working with adaptors, so namespace is required, while before it was optional + ```C++ + ureact::context ctx; + ureact::var_signal src = make_var( ctx, 1 ); + + // before 0.9.0 + ureact::signal minus_src = lift( src, std::negate<>{} ); + + // after 0.9.0 + ureact::signal minus_src = ureact::lift( src, std::negate<>{} ); + ``` + - single argument adaptors like ureact::monitor and ureact::count no longer + require functional call scopes + ```C++ + ureact::context ctx; + ureact::var_signal src = make_var( ctx, 1 ); + + // before 0.9.0 + ureact::signal changes = src | ureact::monitor() | ureact::count(); + + // after 0.9.0 + ureact::signal changes = src | ureact::monitor | ureact::count; + ``` + - unlike free functions, adaptors can't have optional template arguments, so + new adaptors with underscopes are introduced for such cases, because <> + would be required for default case. + ```C++ + ureact::context ctx; + ureact::event_source src = make_source( ctx ); + + // before 0.9.0 + ureact::signal changes = src | ureact::count(); + ureact::signal changes_f = src | ureact::count(); + + // after 0.9.0 + ureact::signal changes = src | ureact::count; + ureact::signal changes_f = src | ureact::count_; + ``` +- BREAKING! yet another great headers rework: + - `ureact/take_drop.hpp` is separated into + `ureact/take.hpp` and `ureact/drop.hpp` + - `ureact/take_drop_while.hpp` is separated into + `ureact/take_while.hpp` and `ureact/drop_while.hpp` + - all adaptors are moved into `ureact/adaptor` subdirectory. + As a result library headers become easier to navigate. +- New adaptor `ureact::once` is introduced. + Or reintroduced, because it was added before and then removed in 0.6.0. + It is merely a `ureact::take(1)` overload with more precise name. +- `ureact::signal_pack` is reworked to hold tuple of signals + instead of tuple of signal references. + It reduces space for errors and reduces artificial complexity + when working with signal_pack with a tiny cost of copying shared + pointers on reactive value construction. + ## [0.8.1](https://github.com/YarikTH/ureact/releases/tag/0.8.1) (2023-01-29) [Full Changelog](https://github.com/YarikTH/ureact/compare/0.8.0...0.8.1) diff --git a/doc/signals_vs_callbacks.md b/doc/signals_vs_callbacks.md index ed909561..751972f9 100644 --- a/doc/signals_vs_callbacks.md +++ b/doc/signals_vs_callbacks.md @@ -186,11 +186,9 @@ What it boils down to, is that the change propagation must be handled by hand. The next example shows how signals can be used for this scenario. -## Final solution: Signals ([run](https://godbolt.org/z/qe3PnK8x7)) +## Final solution: Signals ([run](https://godbolt.org/z/KcfrzKvMM)) ```cpp -#include "ureact/ureact.hpp" - class Shape { public: @@ -216,8 +214,8 @@ ureact::context ctx; Shape myShape( ctx ); // Set dimensions -myShape.width.set( 20 ); -myShape.height.set( 20 ); +myShape.width( 20 ); +myShape.height( 20 ); // Get size const auto curSize = myShape.size(); @@ -226,14 +224,14 @@ const auto curSize = myShape.size(); Every reactive value automatically supports registration of callbacks (they are called observers): ```cpp // Callback on change -observe( myShape.size, - []( int newSize ) { std::cout << "size -> " << newSize << "\n"; } ); +ureact::observe( myShape.size, + []( int newSize ) { std::cout << "size -> " << newSize << "\n"; } ); // Those would work, too -observe( myShape.width, - []( int newWidth ) { std::cout << "width -> " << newWidth << "\n"; } ); -observe( myShape.height, - []( int newHeight ) { std::cout << "height -> " << newHeight << "\n"; } ); +ureact::observe( myShape.width, + []( int newWidth ) { std::cout << "width -> " << newWidth << "\n"; } ); +ureact::observe( myShape.height, + []( int newHeight ) { std::cout << "height -> " << newHeight << "\n"; } ); ``` --------------- diff --git a/include/ureact/version.hpp b/include/ureact/version.hpp index 3ab32e7f..56efb08b 100644 --- a/include/ureact/version.hpp +++ b/include/ureact/version.hpp @@ -13,7 +13,7 @@ #define UREACT_VERSION_MAJOR 0 #define UREACT_VERSION_MINOR 9 #define UREACT_VERSION_PATCH 0 -#define UREACT_VERSION_STR "0.9.0 wip" +#define UREACT_VERSION_STR "0.9.0" #define UREACT_VERSION \ ( UREACT_VERSION_MAJOR * 10000 + UREACT_VERSION_MINOR * 100 + UREACT_VERSION_PATCH ) diff --git a/single_include/ureact/ureact_amalgamated.hpp b/single_include/ureact/ureact_amalgamated.hpp index 1c7129c9..97ef2c1a 100644 --- a/single_include/ureact/ureact_amalgamated.hpp +++ b/single_include/ureact/ureact_amalgamated.hpp @@ -9,8 +9,8 @@ // http://www.boost.org/LICENSE_1_0.txt) // // ---------------------------------------------------------------- -// Ureact v0.9.0 wip -// Generated: 2023-02-12 19:07:00.960740 +// Ureact v0.9.0 +// Generated: 2023-02-12 20:13:30.109790 // ---------------------------------------------------------------- // ureact - C++ header-only FRP library // The library is heavily influenced by cpp.react - https://github.com/snakster/cpp.react @@ -34,7 +34,7 @@ #define UREACT_VERSION_MAJOR 0 #define UREACT_VERSION_MINOR 9 #define UREACT_VERSION_PATCH 0 -#define UREACT_VERSION_STR "0.9.0 wip" +#define UREACT_VERSION_STR "0.9.0" #define UREACT_VERSION \ ( UREACT_VERSION_MAJOR * 10000 + UREACT_VERSION_MINOR * 100 + UREACT_VERSION_PATCH )