defer

Create observable by function that template parameter.

Examples

auto sub = defer!(int, (observer) {
    observer.put(1);
    observer.put(2);
    observer.put(3);
    observer.completed();
});

int countPut = 0;
int countCompleted = 0;
struct A
{
    void put(int n)
    {
        countPut++;
    }

    void completed()
    {
        countCompleted++;
    }
}

assert(countPut == 0);
assert(countCompleted == 0);
auto d = sub.doSubscribe(A());
assert(countPut == 3);
assert(countCompleted == 1);

Meta