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

API design #32

Open
jtpio opened this issue Dec 11, 2024 · 0 comments
Open

API design #32

jtpio opened this issue Dec 11, 2024 · 0 comments

Comments

@jtpio
Copy link
Collaborator

jtpio commented Dec 11, 2024

Currently a consumer of the companion package instantiates a CommandBridge with the following:

const commandBridge = new CommandBridge({ iframeId: 'jupyterlab' })
.commandBridge;

And use it as follows:

const commands = await commandBridge.listCommands();

To access methods exposed by the JupyterLab extension:

const api = {
execute(command: string, args: ReadonlyPartialJSONObject) {
commands.execute(command, args);
},
listCommands() {
return commands.listCommands();
}
};

Some points to consider for expanding the API surface:

  • Currently only execute and listCommands are exposed from the extension, but more could be made available, for example hasCommand, isEnabled and likely more
  • A consumer of CommandBridge on the host page currently does not get good discoverability on what methods are available. This could be improved by defining an interface for the CommandBridge, to get better documentation and completions from IDEs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant