asObservable

alias asObservable = from

Examples

import std.range : iota;

auto obs = from(iota(10));
auto res = new int[10];
auto d = obs.subscribe(res[]);
scope (exit)
    d.dispose();

assert(res.length == 10);
assert(res[0] == 0);
assert(res[9] == 9);
import std.range : iota;

auto obs = iota(10).asObservable();
auto res = new int[10];
auto d = obs.subscribe(res[]);
scope (exit)
    d.dispose();

assert(res.length == 10);
assert(res[0] == 0);
assert(res[9] == 9);
import rx;
import std.range : iota;

auto observable = iota(10).asObservable();
auto observer = new CounterObserver!int;

auto disposable = observable.subscribe(observer);
scope (exit)
    disposable.dispose();

assert(observer.putCount == 10);
assert(observer.completedCount == 1);

Meta