Browse Source

support overriding default options in pods

merge-requests/21/head
rozetko 2 years ago
parent
commit
fc9f0f4a93
  1. 10
      src/models/options.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