defer

Create observable by function that template parameter.

defer
(
E
)
(
)

Examples

1 auto sub = defer!(int, (observer) {
2     observer.put(1);
3     observer.put(2);
4     observer.put(3);
5     observer.completed();
6 });
7 
8 int countPut = 0;
9 int countCompleted = 0;
10 struct A
11 {
12     void put(int n)
13     {
14         countPut++;
15     }
16 
17     void completed()
18     {
19         countCompleted++;
20     }
21 }
22 
23 assert(countPut == 0);
24 assert(countCompleted == 0);
25 auto d = sub.doSubscribe(A());
26 assert(countPut == 3);
27 assert(countCompleted == 1);