Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modularization #54

Closed
ChristopheCVB opened this issue Nov 30, 2022 — with Volta.net · 1 comment · May be fixed by #51
Closed

Modularization #54

ChristopheCVB opened this issue Nov 30, 2022 — with Volta.net · 1 comment · May be fixed by #51
Assignees
Labels
core SDK Core enhancement New feature or request
Milestone

Comments

Copy link
Owner

ChristopheCVB commented Nov 30, 2022

The current way of handling actions works great for small plugins, however, for larger ones, it gets a bit messy.

Add the possibility for Actions and Connectors to be classes that extend something from the SDK.

Basically an abstract class such as:

abstract class TPInvokable<T extends TouchPortalPlugin> {
  protected final T touchPortalPlugin;

  public TPInvokable(T touchPortalPlugin) {
    this.touchPortalPlugin = touchPortalPlugin;
  }

  public abstract void onInvoke();

  public abstract void onListChanged(TPListChangeMessage tpListChangeMessage);
}
  • TPAction would extend it as is
  • TPConnector would extend it and also add the necessary implementation to handle the ConnectorValue

Developers would then have to register those to the TouchPortalPlugin before connecting

// Plugin class
public class MyTPPlugin extends TouchPortalPlugin {}
// TPAction class
@Action(name = "Action One", categoryId = "BaseCategory")
public class ActionOne extends TPAction<MyTPPlugin> {
  @Data
  private String param1;

  public ActionOne(MyTPPlugin myTPPlugin) {
    super(myTPPlugin);
  }

  @Override
  public void onListChanged(TPListChangeMessage tpListChangeMessage) {
    // Update Specific Choices
  }

  @Override
  public void onInvoke() {
    // Do stuff
  }
}
// Later when the plugin starts
MyTPPlugin myTPPlugin = new MyTPPlugin();
myTPPlugin.register(ActionOne.class);
myTPPlugin.connectThenPairAndListen(myTPPlugin);
@ChristopheCVB ChristopheCVB self-assigned this Nov 30, 2022
@Pjiesco
Copy link
Collaborator

Pjiesco commented Nov 30, 2022

I think this would be a really nice addition to the SDK!

@ChristopheCVB ChristopheCVB added enhancement New feature or request and removed to specify labels Nov 30, 2022 — with Volta.net
ChristopheCVB added a commit that referenced this issue Dec 4, 2022
@ChristopheCVB ChristopheCVB linked a pull request Oct 5, 2023 that will close this issue
@ChristopheCVB ChristopheCVB added this to the 9.0.0 milestone Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core SDK Core enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants