Releases: YarikTH/ureact
0.8.0
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
andevent_source
that allow
non-default construction
withoutmake_var
andmake_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
andfold
.
This check works only ifNDEBUG
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
- creation of nodes from callback (
- add
transaction
class that is RAII version ofdo_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>
andmember_event_source<Owner, E>
are added.
Interfacesmember_events_user
,member_signal_user
and
macroUREACT_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
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()
andureact::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 stealop
fromtemp_signal<S>&&
sources like unary signal operators did.
unary signal operators are reworked to call unaryureact::lift()
with standard
unary functors when it is possible (std::negate<> and others) - binary version of
ureact::lift()
is added in formureact::lift(lhs, op, rhs)
.
It is optimized to stealop
fromtemp_signal<S>&&
sources like binary signal
operators did.
binary signal operators are reworked to call binaryureact::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 likeureact::observe()
,
but returns received source instead of observer
see the full changelog
0.6.0
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
tolift
- replace
operator|
overload for signals and function withoperator|
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
andvar_signal
. Usestd::reference<S>
version instead
- revert renaming
see the full changelog
download the header from here
0.5.0
0.4.0
Interface reorganization. One big breaking change. See changelog to find out how to adapt your code
- Add value_base and signal #88 (YarikTH)
- Add operator version of function::get() #87 (YarikTH)
- Rename signal to function #86 (YarikTH)
- Rename var_signal to value #85 (YarikTH)
- Remove deprecated operator ->* #84 (YarikTH)
see the full changelog
download the header from here
0.3.0
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)
-
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)
see the full changelog
download the header from here
0.2.0
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