// Copyright Sebastian Jeckel 2017.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include
#include
#include
#include "react/state.h"
#include "react/event.h"
#include "react/observer.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
/// Example 1 - Reactive class members
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace example1
{
using namespace std;
using namespace react;
Group g;
class Shape
{
public:
StateVar width = StateVar::Create(g, 0);
StateVar height = StateVar::Create(g, 0);
State size = State::Create(g, CalcSize, width, height);
auto GetReactiveMembers() const -> decltype(auto)
{ return std::tie(width, height, size); }
private:
static int CalcSize(int w, int h)
{ return w * h; }
};
void Run()
{
cout