SubjectObject

Represents an object that is both an observable sequence as well as an observer. Each notification is broadcasted to all subscribed observers.

Constructors

this
this()

Members

Aliases

ElementType
alias ElementType = E
Undocumented in source.

Functions

completed
void completed()
currentObserver
Observer!E currentObserver()
Undocumented in source. Be warned that the author may not have intended to support it.
failure
void failure(Exception error)
put
void put(E obj)
subscribe
Disposable subscribe(Observer!E observer)
subscribe
Disposable subscribe(T observer)
unsubscribe
void unsubscribe(Observer!E observer)

Examples

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]));

Meta