LokiCat.Godot.R3.ObservableSignals 1.0.40

There is a newer version of this package available.
See the version list below for details.
dotnet add package LokiCat.Godot.R3.ObservableSignals --version 1.0.40
                    
NuGet\Install-Package LokiCat.Godot.R3.ObservableSignals -Version 1.0.40
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LokiCat.Godot.R3.ObservableSignals" Version="1.0.40" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LokiCat.Godot.R3.ObservableSignals" Version="1.0.40" />
                    
Directory.Packages.props
<PackageReference Include="LokiCat.Godot.R3.ObservableSignals" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LokiCat.Godot.R3.ObservableSignals --version 1.0.40
                    
#r "nuget: LokiCat.Godot.R3.ObservableSignals, 1.0.40"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LokiCat.Godot.R3.ObservableSignals@1.0.40
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LokiCat.Godot.R3.ObservableSignals&version=1.0.40
                    
Install as a Cake Addin
#tool nuget:?package=LokiCat.Godot.R3.ObservableSignals&version=1.0.40
                    
Install as a Cake Tool

LokiCat.Godot.R3.ObservableSignals

A source generator that turns [Signal]-annotated delegates into fully reactive R3 Observable<T> properties.
Supports zero to five signal arguments, automatic EmitSignal(...) wiring, and full Godot editor compatibility.


✨ What It Does

This generator lets you define a signal once using Godot's [Signal] attribute:

[Signal]
public delegate void JumpEventHandler();

💥 And automatically provides:

  • ✅ A backing Subject<T> (_onJump)
  • ✅ A public observable property (OnJump)
  • ✅ A lazy .Subscribe(...) that calls EmitSignal(...) with proper arguments

No need to write Connect(), EmitSignal(), or observable plumbing by hand.


🚀 Quick Start

✅ Define your signal:

[Signal]
public delegate void DamageTakenEventHandler(int amount);

✅ Emit it in your code:

_onDamageTaken.OnNext(42);

✅ Observe it reactively:

OnDamageTaken.Subscribe(amount => GD.Print($"Took {amount} damage!"));

✅ The Godot editor will show a DamageTaken signal.
✅ R3 observers will get updates when the signal fires.


🧠 How It Works

For this:

[Signal]
public delegate void HitEventHandler(Vector3 point, Node target);

The generator emits:

private readonly Subject<(Vector3, Node)> _onHit = new();
private bool _hitConnected;

public Observable<(Vector3, Node)> OnHit {
  get {
    if (!_hitConnected) {
      _hitConnected = true;
      _onHit.Subscribe(value =>
        EmitSignal(nameof(Hit), value.Item1, value.Item2)
      ).AddTo(this);
    }
    return _onHit;
  }
}

✅ One subject powers both EmitSignal(...) and the reactive pipeline.


📦 Installation

dotnet add package LokiCat.Godot.R3.ObservableSignals

Make sure your consumer project defines:

public readonly struct Unit {} // in namespace R3

(Only needed for 0-arg signals.)


✅ Supported Signal Signatures

Delegate Type Observable Type Emission
delegate void JumpEventHandler() Observable<Unit> EmitSignal("Jump")
delegate void DamageEventHandler(int dmg) Observable<int> EmitSignal("Damage", dmg)
delegate void HitEventHandler(Vector3, Node) Observable<(Vector3, Node)> EmitSignal("Hit", ...)

Up to 5 arguments supported. More than 5 triggers a warning.


🚨 Generator Warnings

ID Reason
SIGOBS001 Signal delegate has more than 5 parameters
SIGOBS002 Missing R3.Unit type for 0-arg signals
SIGOBS003 EmitSignal("X") is called manually, but will not emit to OnX

⚡ Best Practices

  • Declare signals once with [Signal]
  • Emit signals using _onX.OnNext(...) — not EmitSignal(...)
  • Observe using OnX.Subscribe(...)
  • Use .Where, .Throttle, .TakeUntil(...) for filtered pipelines
  • Expose Observable<T>s in interfaces to keep logic clean

💡 Advanced

If you manually call EmitSignal(...), observers on OnX will not receive anything.
Only _onX.OnNext(...) propagates to both EmitSignal(...) and the observable.


📜 License

MIT License

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • net7.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.

Version Downloads Last Updated
1.0.70 236 7/2/2025
1.0.69 118 6/21/2025
1.0.68 105 6/21/2025
1.0.65 141 6/19/2025
1.0.64 140 6/19/2025
1.0.63 139 6/19/2025
1.0.62 137 6/19/2025
1.0.61 140 6/19/2025
1.0.60 141 6/19/2025
1.0.59 139 6/19/2025
1.0.58 142 6/19/2025
1.0.57 139 6/19/2025
1.0.56 144 6/19/2025
1.0.55 139 6/19/2025
1.0.54 139 6/18/2025
1.0.53 140 6/18/2025
1.0.52 137 6/18/2025
1.0.51 145 6/18/2025
1.0.47 153 6/14/2025
1.0.40 154 6/14/2025
1.0.38 163 6/14/2025
1.0.37 138 5/9/2025
1.0.36 81 5/9/2025
1.0.35 81 5/9/2025
1.0.34 82 5/9/2025
1.0.33 146 5/8/2025
1.0.32 146 5/8/2025
1.0.31 146 5/1/2025
1.0.30 152 5/1/2025
1.0.29 151 5/1/2025
1.0.28 150 4/30/2025
1.0.26 147 4/30/2025
1.0.25 146 4/30/2025
1.0.24 144 4/30/2025
1.0.23 152 4/30/2025
1.0.22 150 4/30/2025
1.0.21 142 4/30/2025
1.0.20 146 4/30/2025
1.0.19 142 4/29/2025
1.0.18 159 4/29/2025
1.0.17 156 4/28/2025
1.0.16 159 4/27/2025
1.0.15 166 4/27/2025
1.0.14 159 4/27/2025
1.0.13 157 4/27/2025
1.0.12 155 4/27/2025
1.0.11 152 4/27/2025
1.0.9 160 4/27/2025
1.0.7 161 4/27/2025
1.0.1 152 4/27/2025
1.0.0 159 4/27/2025
0.0.6 247 4/19/2025
0.0.5 169 4/19/2025