Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/lib/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class VueStorefrontModule {
return this._c
}

public set config (config) {
this._c = config
}

private static _registeredModules: VueStorefrontModuleConfig[] = []

private static _doesStoreAlreadyExists (key: string) : boolean {
Expand Down Expand Up @@ -60,8 +64,9 @@ export class VueStorefrontModule {

private _extend (extendedConfig: VueStorefrontModule) {
const key = this._c.key
this._c = merge(this._c, extendedConfig.config)
this._c = merge(this._c, extendedConfig)
Logger.info('Module "' + key + '" has been succesfully extended.', 'module')()
debugger;
}

public register (): VueStorefrontModuleConfig | void {
Expand Down
26 changes: 18 additions & 8 deletions src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,30 @@ import { PaymentCashOnDelivery } from './payment-cash-on-delivery';
import { RawOutputExample } from './raw-output-example'
import { Magento2CMS } from './magento-2-cms'

// Some modules that still needs API refactoring are temporary registered in core
// This is how you can adjust any module with application-specific behavior
// const extendedExample = {
// key: 'example',
// afterRegistration: function(isServer, config) {
// console.info('Hello, im extended now!')

// This is how you can extend any of VS modues
// const extendCartVuex = {
// actions: {
// load () {
// console.info('New load function')
// }
// }
// }
// }

// extendModule(extendedExample)
// const cartExtend = {
// key: 'cart',
// afterRegistration: function(isServer, config) {
// console.info('New afterRegistration hook')
// },
// store: { modules: [{ key: 'cart', module: extendCartVuex }] },
// }

// extendModule(cartExtend)

/**
* Some of the modules are registered lazily only when components from module are appearing on current page.
* If you want to use this modules in pages without it's components you need to remember about registering module first
* In VS 1.8 this modules will be semlessly lazyLoaded after proper action dispatch
* - Wishlist
*/
export const registerModules: VueStorefrontModule[] = [
Expand Down
2 changes: 1 addition & 1 deletion src/modules/module-template/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const cacheStorage = initCacheStorage(KEY)
// Put everything that should extend the base app here so it can be later registered as VS module
const moduleConfig: VueStorefrontModuleConfig = {
key: KEY,
store: { modules: [{ key: KEY, module }, { key: 'mailchimp', module: extendMailchimp }], plugin },
store: { modules: [{ key: KEY, module }], plugin },
beforeRegistration,
afterRegistration,
router: { beforeEach, afterEach }
Expand Down
22 changes: 0 additions & 22 deletions src/modules/module-template/store/mailchimp/index.ts

This file was deleted.