@vuemodule/core
v1.0.6
Published
Load modules using the setup function for configuration and invoking hooks.
Downloads
8
Readme
@vuemodule/core

Load modules using the setup function for configuration and invoking hooks.
Installation
Using pnpm
pnpm add @vuemodule/coreUsing yarn
yarn add @vuemodule/coreUsing npm
npm add @vuemodule/coreUsage
Defining a Module
moduleA.js
import { defineModule } from '@vuemodule/core';
export default defineModule('moduleA', () => {
return {
bar: 'baz'
};
});Using Hooks
moduleB.js
import { defineModule, getModuleExports } from '@vuemodule/core';
export default defineModule(({ onInstalled, onUninstall }) => {
onInstalled('moduleA', moduleA => {
console.log(getModuleExports(moduleA)); // { bar: 'baz' };
});
onUninstall('moduleA', moduleA => {
console.log(getModuleExports(moduleA)); // { bar: 'baz' };
});
});Single Module
main.js
Example of using a single module:
import { createModule } from '@vuemodule/core';
const moduleA = createModule(() => import('./moduleA'));
// Install the module
await moduleA.install();
console.log(moduleA.exports); // The object returned by the module's setup function
// Uninstall the module
await moduleA.uninstall();Multiple Modules
main.js
Example of using multiple modules with called hooks:
import { createModules, createModule } from '@vuemodule/core';
const modules = createModules([
() => import('./moduleA'),
() => import('./moduleB')
]);
// Install all modules
await modules.install();
console.log(modules.get('moduleA').exports); // The object returned by the module's setup function
// Uninstall all modules
await modules.uninstall();License
Licensed under the MIT License.
