Skip to content

Feature Request: An IsResolved property/method to be included to check if a node has had it's dependencies resolved #54

Description

@Soren025

One thing I find my self doing is the following structure.

[Meta(typeof(IDependent))]
public partial class Foo: Node
{
    [Dependency]
    public Bar Bar => this.DependOn<Bar>();
    
    private bool IsResolved { get; set; }
    
    public override void _Notification(int what)
    {
        this.Notify(what);
    }

    public void OnResolved()
    {
        Bar.SomeEvent += OnSomeEvent;
        IsResolved = true;
    }

    public override void _ExitTree()
    {
        if (IsResolved)
        {
            Bar.SomeEvent -= OnSomeEvent;
        }
    }

    private void OnSomeEvent() { }
}

Foo wants to unregister events from a dependency when it's removed from it's parent, but if it's removed before OnResolved() is called it might result in errors due to an unresolved dependency. So I have found the need to add a bool property to check if OnResolved() has been called.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions