import std.array : appender; auto data = appender!(int[])(); auto subject = new SubjectObject!int; auto disposable = subject.subscribe(observerObject!(int)(data)); assert(disposable !is null); subject.put(0); subject.put(1); import std.algorithm : equal; assert(equal(data.data, [0, 1])); disposable.dispose(); subject.put(2); assert(equal(data.data, [0, 1]));
Represents an object that is both an observable sequence as well as an observer. Each notification is broadcasted to all subscribed observers.