Skip to content

Commit

Permalink
chore: remove redundant methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Jun 21, 2019
1 parent 472586e commit 8d765aa
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions components/core/config/config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ export class NzConfigService {
this.config = defaultConfig || {};
}

getDefaultConfig(componentName: keyof NzConfig, propName: string): any {
const componentConfig: any = this.config[componentName] || {};
return componentConfig[propName] || null;
}

getConfigChangeEventForComponent(componentName: keyof NzConfig): Observable<void> {
return this.configUpdated$.pipe(
filter(n => n === componentName),
Expand All @@ -47,11 +42,6 @@ export class NzConfigService {
this.config[componentName] = { ...this.config[componentName], ...(value || {}) };
this.configUpdated$.next(componentName);
}

setCompleteConfig(config: NzConfig): void {
this.config = { ...config };
this.configUpdated$.next();
}
}

// tslint:disable:no-invalid-this
Expand Down Expand Up @@ -88,11 +78,12 @@ export function WithConfig<T>(componentName: keyof NzConfig, innerDefaultValue?:
return originalValue;
}

// NOTE: Every component that supports global config should have `NzConfigService` injected as `nzConfigService`.
// TODO: use a `get` function to simplify these code.
const componentConfig = this.nzConfigService.config[componentName];
const configValue = isDefined(componentConfig) ? componentConfig[propName] : undefined;
const defaultValue = isDefined(configValue) ? configValue : innerDefaultValue;

return defaultValue;
return isDefined(configValue) ? configValue : innerDefaultValue;
},
set(value?: T): void {
if (originalDescriptor && originalDescriptor.set) {
Expand Down

0 comments on commit 8d765aa

Please sign in to comment.