Allows to get an observables for property changed events.
Deprecated Package Version
Reason: Legacy
Thank you for using `ReactiveMarbles.ObservableEvents.SourceGenerator`, we have now moved the onward development of this to https://github.com/reactiveui/Primitives with the package `ReactiveUI.Primitives.ObservableEvents` to migrate you will need to update the package and using declarations, thank you.
Get Started
| Product | Versions |
|---|---|
| .NET Standard |
README
Observable Event Generator
This project is a .NET source generator which produces IObservable<T> for events contained within a object including all base classes. ObservableEvents generator will convert events within an assembly and create observable wrappers for them, it is based on Pharmacist and uses .NET Source Generator technology.
NuGet Packages
Make sure your project is using the newer PackageReference inside your CSPROJ. The older style is buggy and should be moved away from regardless. See here for discussions how to upgrade.
Install the following packages to start using Observable Events.
| Name | Platform | NuGet |
|---|---|---|
| ReactiveMarbles.ObservableEvents.SourceGenerator | Core - Libary |
Manual Installation
Include the following in your .csproj file
<PackageReference
Include="ReactiveMarbles.ObservableEvents.SourceGenerator"
Version="1.0.2"
PrivateAssets="all" />
The PrivateAssets will prevent the ObservableEvents source generator from being inherited by other projects.
How to use
Instance Based
It injects a class for instance based events into your source code which will expose a extension method called Events(). You need to include the namespace ReactiveMarbles.ObservableEvents to access to the extension method. You can then use this to get IObservable<T> instances from your events.
using ReactiveMarbles.ObservableEvents;
public void MyClass : INotifyPropertyChanged
{
// Assumes this belong in a class with a event called PropertyChanged.
public void RunEvents()
{
this.Events().PropertyChanged.Subscribe(x => Console.WriteLine($"The {x} property has changed"));
}
public event PropertyChangedEventHandler PropertyChanged;
}
Static Events
You must use include a attribute GenerateStaticEventObservables on the assembly level for a particular class. This will generate a class RxEvents in the same namespace as the specified class.
[assembly: GenerateStaticEventObservablesAttribute(typeof(StaticTest))]
public static class StaticTest
{
public static event EventHandler? TestChanged;
}
Downloads by Version
Similar & Alternative Packages
Hand-picked matching NuGet libraries based on tags & ecosystem
Depended On By
Find packages that declare this package as a dependency. NuGet does not provide a reverse-dependency endpoint, so candidates are checked on demand.
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.