Here, we will talk about reactive programming in C# and .NET framework using the Rx.NET library. Reactive programming is widely in use in desktop and mobile applications nowadays.
For this sample, I used ReactiveUI to implement MVVM in the project. However, the ReactiveUI gives us a model-view-ViewModel framework for all .NET platforms. I chose a WPF application to implement the samples. For more information about the ReactiveUI and how to implement the MVVM, you can check the following links:
https://www.reactiveui.net/
https://github.com/reactiveui/reactiveui
In all the samples, we widely use Observables. If you are not familiar with the observer design pattern, visit the following links:
https://learn.microsoft.com/en-us/dotnet/standard/events/observer-design-pattern
https://learn.microsoft.com/en-us/dotnet/api/system.iobservable-1?view=net-7.0
https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.inotifypropertychanged?view=net-7.0
The best way to show the execution pipeline of the observables sequence is using marble diagrams. Hence, I use it in this repo and my blog as well. In the following figure, execution of the observables sequence is represented by a marble diagram.
The following examples show some of the main Rx operations using a marble diagram.
The Take(int count) operation is used to take a specific number of elements from an observable sequence.
The Delay(TimeSpan dueTime) operation is used to receive the values of an observable sequence by delay after the subscription.
The Where(Func<TSource, bool> predicate) operation is used to filter out the values of an observable sequence.
https://parsakarami.com/Blog/Main/Post/Receiving_buffered_items_with_wait_time_intervals_in_RxNET