diff --git a/client/src/modules/pluginapi.js b/client/src/modules/pluginapi.js index c62e142b..0ebc547f 100644 --- a/client/src/modules/pluginapi.js +++ b/client/src/modules/pluginapi.js @@ -9,6 +9,7 @@ */ import { ClientLogger as Logger } from 'common'; +import Settings from './settings'; import PluginManager from './pluginmanager'; import ThemeManager from './thememanager'; import Events from './events'; @@ -66,6 +67,15 @@ export default class PluginApi { } } + getSetting(set, category, setting) { + return Settings.get(set, category, setting); + } + get Settings() { + return { + get: this.getSetting.bind(this) + }; + } + async getPlugin(plugin_id) { // This should require extra permissions return await PluginManager.waitForPlugin(plugin_id); diff --git a/tests/plugins/Example/index.js b/tests/plugins/Example/index.js index 832e106b..ee5fb848 100644 --- a/tests/plugins/Example/index.js +++ b/tests/plugins/Example/index.js @@ -7,7 +7,12 @@ module.exports = (Plugin, Api, Vendor) => { onStart() { Events.subscribe('TEST_EVENT', this.eventTest); Logger.log('onStart'); - Logger.log(`Setting "default-0" value: ${this.getSetting('default-0')}`); + Logger.log(`Plugin setting "default-0" value: ${this.getSetting('default-0')}`); + Logger.log(`Internal setting "core/default/test-setting" value: ${Api.Settings.get('core', 'default', 'test-setting')}`); + + Events.subscribe('setting-updated', setting => { + console.log('Received internal setting update:', setting); + }); const exampleModule = new (Api.import('Example Module')); Logger.log(`2+4=${exampleModule.add(2, 4)}`);