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

Add a 'defer' option to the autoStart argument #588

Merged
merged 6 commits into from
Jun 14, 2023

Conversation

brichet
Copy link
Contributor

@brichet brichet commented May 26, 2023

This PR adds an optional deferred flag to the plugin options.
EDIT This PR allows to set the value 'defer' to the autoStart argument of a plugin.

This is related to jupyterlab/jupyterlab#14576.

It also adds a function for activating all deferred plugins, preferably after application startup.

It does not modify the behavior of autoStart, which means that if autoStart: false, the plugin will not be activated using the dedicated function.

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @brichet

I have some suggestions / questions

@@ -59,6 +59,14 @@ export interface IPlugin<T extends Application, U> {
*/
autoStart?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use autoStart?: boolean | 'defer' instead of introducing another flag? This will be consistent with the actual three available state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it should work without breaking the current API.

packages/application/src/index.ts Outdated Show resolved Hide resolved
packages/application/src/index.ts Outdated Show resolved Hide resolved
* @returns A list of promises which will each resolve when the related
* plugin is activated or rejects with an error if it cannot be activated.
*/
activateDeferredPlugins(): Promise<void>[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not wrapping the list of promise in a Promise.all to get a single promise?

brichet and others added 3 commits June 13, 2023 10:25
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
… promise when activating all deferred plugins
@brichet brichet changed the title Add an optional 'deferred' to the plugin options Add a 'defer' option to the autoStart argument Jun 13, 2023
@brichet
Copy link
Contributor Author

brichet commented Jun 13, 2023

Thanks @fcollonval, I updated the PR to include your suggestions.

@brichet
Copy link
Contributor Author

brichet commented Jun 13, 2023

This is backward-compatible, so an extension with autoStart: 'defer' will still work with a previous version of lumino.
This is seen as autoStart: true, the extension will not be deferred but will still be loaded.

Copy link
Member

@fcollonval fcollonval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @brichet

i took the liberty to change slightly the activateDeferredPlugins to not return an array of void and some technical debts maintenance removing a Map that is used for a Set.

@brichet
Copy link
Contributor Author

brichet commented Jun 13, 2023

removing a Map that is used for a Set.

Thanks @fcollonval, I can't remember why I first used a Map for this use case.

@fcollonval
Copy link
Member

removing a Map that is used for a Set.

Thanks @fcollonval, I can't remember why I first used a Map for this use case.

It is not on you it was there from the start of the project 😉 . I think this was used to ensure id uniqueness back in the day where Set did not exist.

@fcollonval fcollonval merged commit 7fbfae3 into jupyterlab:main Jun 14, 2023
gabalafou pushed a commit to gabalafou/lumino that referenced this pull request Jul 7, 2023
* Add an optional 'deferred' to the plugin options

* Update packages/application/src/index.ts

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* Update packages/application/src/index.ts

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>

* Uses the autostart argument to defer the plugins, and return only one promise when activating all deferred plugins

* Fix tests

* Don't return void[] from activateDeferredPlugins

---------

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
Co-authored-by: Frédéric Collonval <fcollonval@gmail.com>
@brichet brichet deleted the deferred-plugins branch July 19, 2023 11:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants