Skip to content

Commit 244fa1c

Browse files
committed
Updated readme.
1 parent cd48018 commit 244fa1c

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,30 @@ SignalT<int> area = MakeSignal(
9393
return w * h;
9494
});
9595
```
96-
```
97-
// Signal values can be accessed imperativly
96+
Signal values can be accessed imperatively:
97+
```C++
9898
cout << "area: " << area.Value() << endl; // => area: 2
9999
100-
// VarSignals can be manipulated imperatively
101-
width.Set(10);
102100
// Width changed, so area is re-calculated automatically
101+
width.Set(10);
103102
104103
cout << "area: " << area.Value() << endl; // => area: 20
105104
```
106105

106+
Or, instead of using `Value()` to pull the new value, callback functions can be registered to receive notifications on a change:
107+
```C++
108+
Observe(area, [] (int newValue) {
109+
cout << "area changed: " << newValue << endl;
110+
});
111+
```
112+
107113
Overloaded operators for signal types allow to omit `MakeSignal` in this case for a more concise syntax:
108114
```C++
109115
// Lift as reactive expression - equivalent to previous example
110116
SignalT<int> area = width * height;
111117
```
112118

113-
### Event streams and Observers
119+
### Event streams
114120

115121
Event streams represent flows of discrete values. They are first-class objects and can be merged, filtered, transformed or composed to more complex types:
116122

@@ -129,7 +135,7 @@ EventSourceT<Token> rightClicked = MakeEventSource<D>();
129135
EventsT<Token> merged = leftClicked | rightClicked;
130136

131137
// React to events
132-
auto obs = Observe(merged, [] (Token) {
138+
Observe(merged, [] (Token) {
133139
cout << "clicked!" << endl;
134140
});
135141
```

0 commit comments

Comments
 (0)