R3Extensions.ObservableEvents.SourceGenerator
1.3.3
dotnet add package R3Extensions.ObservableEvents.SourceGenerator --version 1.3.3
NuGet\Install-Package R3Extensions.ObservableEvents.SourceGenerator -Version 1.3.3
<PackageReference Include="R3Extensions.ObservableEvents.SourceGenerator" Version="1.3.3" />
<PackageVersion Include="R3Extensions.ObservableEvents.SourceGenerator" Version="1.3.3" />
<PackageReference Include="R3Extensions.ObservableEvents.SourceGenerator" />
paket add R3Extensions.ObservableEvents.SourceGenerator --version 1.3.3
#r "nuget: R3Extensions.ObservableEvents.SourceGenerator, 1.3.3"
#addin nuget:?package=R3Extensions.ObservableEvents.SourceGenerator&version=1.3.3
#tool nuget:?package=R3Extensions.ObservableEvents.SourceGenerator&version=1.3.3
<a href="https://github.com/reactivemarbles/observableevents"> <img width="150" src="./images/logo.png"/> </a>
Observable Event Generator for R3
This repository's implementation is identical to the upstream, with only structural adjustments. Icon from icon8
This project is a .NET source generator which produces Observable<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 |
---|---|---|
R3Extensions.ObservableEvents.SourceGenerator | Core - Libary |
Manual Installation
Include the following in your .csproj file
<PackageReference
Include="R3.ObservableEvents.SourceGenerator"
Version="1.3.0"
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 R3.ObservableEvents
to access to the extension method. You can then use this to get Observable<T>
instances from your events.
using R3.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;
}
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.