Browse Source

Merge branch 'support-overriding-default-options-in-pods' into 'main'

Support overriding default options in pods

See merge request chartwerk/core!21
merge-requests/22/merge
rozetko 3 years ago
parent
commit
b63e672045
  1. 2
      package.json
  2. 10
      src/models/options.ts

2
package.json

@ -1,6 +1,6 @@
{
"name": "@chartwerk/core",
"version": "0.6.1",
"version": "0.6.2",
"description": "Chartwerk core",
"main": "dist/index.js",
"types": "dist/index.d.ts",

10
src/models/options.ts

@ -8,7 +8,6 @@ import {
} from '../types';
import lodashDefaultsDeep from 'lodash/defaultsDeep';
import lodashMap from 'lodash/map';
import lodashCloneDeep from 'lodash/cloneDeep';
import has from 'lodash/has';
@ -100,7 +99,7 @@ const DEFAULT_OPTIONS: Options = {
export class CoreOptions<O extends Options> {
_options: O;
_defaults: Options = DEFAULT_OPTIONS;
_coreDefaults: Options = DEFAULT_OPTIONS;
constructor(options: O) {
this.setOptions(options);
@ -111,7 +110,12 @@ export class CoreOptions<O extends Options> {
}
protected setOptions(options: O): void {
this._options = lodashDefaultsDeep(lodashCloneDeep(options), this._defaults);
this._options = lodashDefaultsDeep(lodashCloneDeep(options), this.defaults);
}
// this getter can be overrited in Pod
protected get defaults(): Options {
return this._coreDefaults;
}
get allOptions(): O {

Loading…
Cancel
Save