C++React是C++11的一个Reactive编程库。
示例代码:
using namespace std;using namespace react;// Defines a reactive domain that uses single-threaded, sequential updatingREACTIVE_DOMAIN(D, sequential)// Defines aliases for types of the given domain,// e.g. using VarSignalT<X> = VarSignal<D,X>USING_REACTIVE_DOMAIN(D)// Two reactive variables that can be manipulated imperatively// to input external changesVarSignalT<int> width = MakeVar<D>(1);VarSignalT<int> height = MakeVar<D>(2);// A signal that depends on width and height and multiplies their valuesSignalT<int> area = MakeSignal( With(width, height), [] (int w, int h) { return w * h; });
评论