Skip to content

Replace standard fields with a state system #31

Description

@SomeSourceCode

Description

The current implementation stores values like x, y, layoutX, layoutY, visible, etc. as standard fields. This makes it impossible to listen for changes.

Instead, those values should be stored inside observable states. This enables listening for changes and reacting accordingly, such as firing updates, triggering re-renders, etc.

Some states should be read-only, such as x, y, since they're calculated based on other values.

Motivation

This is motivated by #19. AnvilGui should support an observable text input field.

Expected Code

// getters and setter persist:
node.setLayoutX(x);
node.getLayoutX();

// states can be accessed and observed:
node.layoutXState().observe((oldValue, newValue) ->{
    // ...
});

// read-only states can't be set:
node.xState().set(x); // won't compile

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions