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(plugins): add support for plugin decorators #2971

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from

Conversation

Pavel910
Copy link
Collaborator

@Pavel910 Pavel910 commented Jan 23, 2023

Changes

This PR adds support for registering plugin decorators. This is useful for our old POJO plugins (and we have many of those), as very often in our code we do conditional checks if certain optional plugin properties are set, and if so, execute those functions. This adds a lot of overhead in various views where same plugin types are being used.

Using decorators we can now register decorators (classes), which decorate (wrap) the original plugin, and that way we can implement default behavior on those optional plugin functions.

Why not just switch the original plugins with classes?

Because there are many plugins in the user land, which would break the app if we just assumed that everybody is now using classes. This way we can add a decorator and achieve the same result without breaking anything, and remove the redundant conditionals from our main logic.

@brunozoric @adrians5j please have a look at the tests and post your thoughts.

How Has This Been Tested?

Jest tests.

Copy link
Contributor

@brunozoric brunozoric left a comment

Choose a reason for hiding this comment

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

Looks ok.
One small change. Left a comment on it.

packages/plugins/src/PluginsContainer.ts Outdated Show resolved Hide resolved
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

Successfully merging this pull request may close these issues.

None yet

2 participants