Skip to content

Commit 88090f7

Browse files
committed
progress
1 parent b70012f commit 88090f7

8 files changed

Lines changed: 313 additions & 330 deletions

File tree

‎examples/src/BasicObservers.cpp‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,17 @@ namespace example2
5858
{
5959
cout << "Example 2 - Detaching observers manually" << endl;
6060

61-
Observer obs(
62-
[] (EventRange<> in)
63-
{
64-
for (auto _ : in)
65-
cout << "Triggered!" << endl;
66-
},
67-
trigger);
68-
69-
trigger.Emit(); // output: Triggered!
70-
71-
obs.Cancel(); // Remove the observer
61+
{
62+
Observer obs(
63+
[] (EventRange<> in)
64+
{
65+
for (auto _ : in)
66+
cout << "Triggered!" << endl;
67+
},
68+
trigger);
69+
70+
trigger.Emit(); // output: Triggered!
71+
}
7272

7373
trigger.Emit(); // no output
7474

‎examples/src/BasicSignals.cpp‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ namespace example1
2626
string ConcatFunc(string first, string second)
2727
{ return first + string(" ") + second; }
2828

29+
void PrintFunc(const string& s)
30+
{ cout << s << endl; }
31+
2932
// Defines a group.
3033
// Each group represents a separate dependency graph.
3134
// Reactives from different groups can not be mixed.
@@ -40,18 +43,14 @@ namespace example1
4043

4144
void Run()
4245
{
43-
cout << "Example 1 - Hello world" << endl;
46+
Observer obs{ PrintFunc, bothWords };
4447

45-
cout << bothWords.Value() << endl;
48+
cout << "Example 1 - Hello world" << endl;
4649

4750
firstWord <<= string("Hello");
4851

49-
cout << bothWords.Value() << endl;
50-
5152
secondWord <<= string("World");
5253

53-
cout << bothWords.Value() << endl;
54-
5554
cout << endl;
5655
}
5756
}
@@ -150,8 +149,8 @@ namespace example4
150149
data.Modify([] (vector<string>& data)
151150
{ data.push_back("World"); });
152151

153-
for (const auto& s : data.Value())
154-
cout << s << " ";
152+
// for (const auto& s : data.Value())
153+
// cout << s << " ";
155154
cout << endl;
156155
// output: Hello World
157156

0 commit comments

Comments
 (0)