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

feat: Add removePlugins method to plugin registry #799

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions dist/app/PluginRegistry.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/app/PluginRegistry.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions dist/app/PluginRegistry.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/app/PluginRegistry.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/app/PluginRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ export class PluginRegistry implements IRegistry {
return instance[f];
}

/**
* Removes all registered plugins if no custom remove function is provided.
* @param remove Custom function to remove only specific plugins.
* @example
* ```ts
* PluginRegistry.getInstance().removePlugins((desc) => desc.type === 'tdpView');
* // => removes all plugins of type "tdpView"
* ```
*/
public removePlugins<T extends IPluginDesc>(remove: (desc: T) => boolean = () => false): void {
this.registry = this.registry.filter((d) => !remove(<T>d));
}

private static instance: PluginRegistry;

public static getInstance(): PluginRegistry {
Expand Down