Skip to content

Conversation

@devnatan
Copy link
Owner

@devnatan devnatan commented Oct 4, 2023

This is needed to allow custom components to access Platform-designed states.
A StateAccess interface was created, both AbstractComponent and PlatformView will implement it.

Before states was created with internal API methods, accessing StateRegistry, casting root to PlatformView (that couldn't work sometimes), a completely mess

Now states can be used like in a View and can be integrated with State-Components like Pagination or regular components like ItemComponent.

@Data
class MyCustomComponent extends AbstractComponent {

    // Components inherit states from context that inherits from root, initialState should work as well.
    private final State<String> initialText = initialState();

    @Override
    public void render(@NotNull IFRenderContext render) {
        // do something with initial state
    }

}

Also needed to identify State accessors in Inventory Framework IntelliJ Tooling Plugin

@devnatan devnatan added api-design Major changes to the high-level API refactor labels Oct 4, 2023
@devnatan devnatan added this to the Release v3.0.2 milestone Oct 4, 2023
@devnatan devnatan self-assigned this Oct 4, 2023
@devnatan devnatan marked this pull request as ready for review October 7, 2023 15:57
@devnatan devnatan merged commit 8770e39 into main Oct 7, 2023
@devnatan devnatan deleted the refactor/platform-state-factory branch October 7, 2023 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-design Major changes to the high-level API refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants