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 dynamic synced plugin config provider #1064

Merged
merged 4 commits into from
Mar 19, 2023

Conversation

Araxeus
Copy link
Collaborator

@Araxeus Araxeus commented Mar 11, 2023

There are atleast 3 open PR's which could use this: #1054 , #1065 and #1079

Synced PluginConfig

This PR allows all plugin to easily have access to synced config on both main & renderer (back/front)

This is potentialy very useful, after all plugins implement this class - most plugin options shouldn't require a restart to apply


Example

in ./plugins/my-plugin/config.js:

 const { PluginConfig } = require("../../config/dynamic");
 const config = new PluginConfig("plugin-name", { enableFront: true });
 module.exports = { ...config };

in ./plugins/my-plugin/back.js:

const config = require("./config");

config.set("myOption", true)

assert.equal(config.get("myOption"), true);

in ./plugins/my-plugin/front.js:

const config = require("./config");

await config.set("myOption", true)

assert.equal(
  await config.get("myOption"),
  true,
);

Example 2

The config could also be initialized straight from back.js (tho I doubt there's ever a reason to do that)

 module.exports = (win, options) => {
  const config = new PluginConfig("plugin-name", {
  	enableFront: true,
  	initialOptions: options,
  });
  setupMyPlugin(win, config);
 };

TODO

@th-ch th-ch merged commit 83eb187 into th-ch:master Mar 19, 2023
@Araxeus Araxeus mentioned this pull request Mar 31, 2023
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