Cysharp / R3

The new future of dotnet/reactive and UniRx.
MIT License
2.1k stars 92 forks source link

AddTo support for Godot Node #207

Closed minami110 closed 3 months ago

minami110 commented 4 months ago

Add AddTo extension method for Godot.Node class.

public partial class Foo :  Node
{
    private readonly Subject<Unit> _s = new();

    public override void _Ready()
    {
        _s.AddTo(this);
    }
}

Disposable will be disposed when node has been exited tree.
If this method is called before enter tree, there is no guarantee that it will be dispiosed, so a warning log is displayed if it is called on a constructor or the like.

neuecc commented 4 months ago

thanks, I'll check soon!

neuecc commented 3 months ago

I think it's good, I'll merge it!