File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 22
33# lars::Event
44
5- A thread-safe C++11 event-listener template.
5+ A thread-safe C++11 event-listener template and observable value implementation .
66
77# Example
88
9+ ## lars::Event
910
11+ ``` c++
12+ lars::Event<float ,float > onClick;
13+ auto observer = onClick.createObserver([](auto x, auto y){ handleClick (x,y); });
14+ onClick.emit(0,0); // emits event to all observers
15+ observer.reset(); // removes observer from event
16+ ```
17+
18+ ## lars::ObservableValue
19+
20+ ```c++
21+ ObservableValue a = 1;
22+ ObservableValue b = 2;
23+ DependentObservableValue sum([](auto a, auto b){ return a+b; },a,b);
24+ DependentObservableValue resultString([](auto v){ return "The result is " + std::to_string(v); }, sum);
25+ resultString.onChange.connect([](auto &r){ std::cout << r << std::endl; });
26+ ```
1027
1128# Installation and usage
1229
You can’t perform that action at this time.
0 commit comments