Sourcing events
Sourcing events is the ability to obtain from a particular source where few useful events are usable in reactive programming.
Tip
If you are searching for the EventSourcing
pattern, take a look at
Chapter 7, Advanced Techniques
.
As already pointed out in the previous chapter, reactive programming is all about event message handling. Any event is a specific occurrence of some kind of handleable behavior of users or external systems. We can actually program event reactions in the most pleasant and productive way for reaching our software goals.
In the following example, we will see how to react to CLR events. In this specific case, we will handle filesystem events by using events from the System.IO.FileSystemWatcher
class that gives us the ability to react to the filesystem's file changes without the need of making useless and resource-consuming polling queries against the file system status.
Here's the observer and observable implementation:
public sealed class NewFileSavedMessagePublisher...