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(core): add context to extension builder #22

Merged
merged 1 commit into from
Oct 13, 2022
Merged

Conversation

d3m1d0v
Copy link
Member

@d3m1d0v d3m1d0v commented Oct 12, 2022

The key-value storage context has been added to the ExtensionBuilder, which allows you to transfer data between extensions.

Usage:

const builder = new ExtensionBuilder(
  ExtensionBuilder.createContext()
    .set('globalflag', true)
);

const Extension0: ExtensionAuto = (builder) => {
  builder.context.set('someflag', true);
  // ...
};

const Extension1: ExtensionAuto = (builder) => {
  if (builder.context.get('globalflag') === true) {
    // ...
  }
  if (builder.context.get('someflag') === true) {
    // ...
  }
};

builder.use(Extension0).use(Extension1);

@d3m1d0v d3m1d0v requested a review from smsochneg October 12, 2022 16:01
@yc-ui-bot
Copy link
Contributor

Preview is ready.

@d3m1d0v d3m1d0v marked this pull request as ready for review October 13, 2022 12:40
@d3m1d0v d3m1d0v merged commit dc66438 into master Oct 13, 2022
@d3m1d0v d3m1d0v deleted the builder-context branch October 13, 2022 16:42
makhnatkin pushed a commit that referenced this pull request May 28, 2024
The key-value storage context has been added to the ExtensionBuilder, which allows you to transfer data between extensions.
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.

3 participants