Giter VIP home page Giter VIP logo

cpp.react's Introduction

C++React

C++React is reactive programming library for C++14. It enables the declarative definition of data dependencies between state and event flows. Based on these definitions, propagation of changes is handled automatically.

Here's a simple example:

using namespace react;

void AddNumbers(int a, int b)  { return a + b; }

// Two state variable objects. You can change their values manually.
auto a = StateVar<int>::Create(0);
auto b = StateVar<int>::Create(0);

// Another state object. Its value is calculated automatically based on the given function and arguments.
// If the arguments change, the value is re-calculated.
auto sum = State<int>::Create(AddNumbers, a, b);

// sum == 0
a.Set(21);
// sum == 21
b.Set(21);
// sum == 42

The underlying system constructs a dependency graph to collect which values are affected by a change, and in which order they have to be re-calculated. This guarantees several properties:

  • correctness - no updates are forgotten;
  • consistency - no value is updated before all its incoming dependencies have been updated;
  • efficiency - no value is re-calculated more than once per update cycle, and changes are only propagated along paths where a new value is different from the old one.

The system also knows when it's safe to update values in parallel from multiple threads, and it can do live profiling to decide when that's worthwhile.

Development status

I'm currently in the process of rewriting the library more or less from scratch and many things are still broken or outdated.

The old, but stable and documented version is still available in this branch.

cpp.react's People

Contributors

schlangster avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.