
Reactive Programming
Reactive Extensions (Rx), IObservable, operators, schedulers, backpressure (optional, less common in modern web APIs)
1What is the IObservable<T> interface in Reactive Extensions (Rx.NET)?
What is the IObservable<T> interface in Reactive Extensions (Rx.NET)?
답변
IObservable<T> is the fundamental interface in Rx.NET that represents a push-based data source. It exposes a Subscribe method allowing observers to subscribe to receive asynchronous notifications. It's the reactive counterpart to IEnumerable<T>: while IEnumerable pulls data synchronously, IObservable pushes data asynchronously to subscribers.
2What are the three methods of the IObserver<T> interface in Rx.NET?
What are the three methods of the IObserver<T> interface in Rx.NET?
답변
IObserver<T> defines three methods: OnNext(T value) to receive each element of the sequence, OnError(Exception error) to handle errors and signal the end of the sequence in case of failure, and OnCompleted() to indicate that the sequence completed successfully. These three methods form the observer contract which guarantees that after OnError or OnCompleted, no further OnNext will be called.
3What is the main difference between IEnumerable<T> and IObservable<T>?
What is the main difference between IEnumerable<T> and IObservable<T>?
답변
IEnumerable<T> is a pull model where the consumer requests data synchronously with GetEnumerator() and MoveNext(). IObservable<T> is a push model where the source pushes data asynchronously to subscribers via Subscribe(). IEnumerable blocks the calling thread during iteration, while IObservable enables non-blocking operations and composition of asynchronous events with LINQ operators.
What is the role of the Select operator in Rx.NET?
How does the Where operator work in Rx.NET?
+21 면접 질문