1 int subscribeCount = 0; 2 class TestObservable : Observable!int 3 { 4 Disposable subscribe(Observer!int observer) 5 { 6 subscribeCount++; 7 return NopDisposable.instance; 8 } 9 } 10 11 auto test = new TestObservable; 12 auto observable = observableObject!int(test); 13 assert(observable is test); 14 assert(subscribeCount == 0); 15 auto d = observable.subscribe(null); 16 assert(subscribeCount == 1);
Wraps subscribe method in virtual function.