Skip to content

How to hide an input in a node that is defined as a class ? #463

@Dylan190774

Description

@Dylan190774

I'm trying to disable/hide an input, depending on if another input is connected or not.
I'm using the class-based approach to create the node.

In the documentation I see:

    onUpdate({ operation }) {
        if (operation === "Sine") {
            return {
                inputs: {
                    input1: () => new NumberInterface("Input", 0),
                },
            };
        } else {
            return {
                inputs: {
                    input1: () => new NumberInterface("Input", 0),
                    input2: () => new NumberInterface("Input", 0),
                },
            };
        }
    },

but how do I do this with a class, since there seems no onUpdate available there?
This is my class definition:

 class BaseNode<I extends Inputs = Inputs, O extends Outputs = Outputs> extends DynamicNode<
  I,
  O
> {
  public type = 'BaseNode';
  public override get title(): string {
    return 'Base';
  }

  public inputs = {
    input1: new NumberInterface('Input 1', 1),
    input2: new NumberInterface('Input 2', 1),
  } as NodeInterfaceDefinition<I>;

  public outputs = {
    output: new NodeInterface('Output', 1),
  } as NodeInterfaceDefinition<O>;

  public constructor() {
    super();
  }
  public override load(data: unknown): void {
  }
  public override calculate: CalculateFunction<I, O> = (inputs, outputs) => {
    return {} as O;
  };
}

I'd like to achieve that for example, when there is nothing connected to input1, then input2 is hidden.

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions