IObserver<T> interfaces might look at little weird at first, but they are actually very closely related to the well-known
IEnumerator<T>. In fact, they are mathematical duals. It’s normal you perceive this as rather abstract, but it’s rather simple. Follow me.
From our discussion about statements, recall that
IEnumerable<T>’s primary use is the
foreach loop statement. Collections implement this interface, allowing us to retrieve their data by pulling it out one by one. In fact, the consumer is in control, which makes this an interactive mechanism. To pull data from the source, the consumer asks the enumerator for more data by calling
MoveNext and ...