feat(config): expose getMode() and deprecate Config (#19104)

This commit is contained in:
Manu MA
2019-09-25 17:21:43 +02:00
committed by GitHub
parent bfa17d1594
commit 0f05ea4245
2 changed files with 15 additions and 1 deletions

View File

@ -33,6 +33,7 @@ export class Config {
} }
set(key: keyof IonicConfig, value?: any) { set(key: keyof IonicConfig, value?: any) {
console.warn(`[DEPRECATION][Config]: The Config.set() method is deprecated and will be removed in the next major release.`);
const c = getConfig(); const c = getConfig();
if (c) { if (c) {
c.set(key, value); c.set(key, value);
@ -44,7 +45,7 @@ export const ConfigToken = new InjectionToken<any>('USERCONFIG');
const getConfig = (): CoreConfig | null => { const getConfig = (): CoreConfig | null => {
if (typeof (window as any) !== 'undefined') { if (typeof (window as any) !== 'undefined') {
const Ionic = (window as IonicWindow).Ionic; const Ionic = (window as any as IonicWindow).Ionic;
if (Ionic && Ionic.config) { if (Ionic && Ionic.config) {
return Ionic.config; return Ionic.config;
} }

View File

@ -199,3 +199,16 @@ export const setupConfig = (config: IonicConfig) => {
}; };
return win.Ionic.config; return win.Ionic.config;
}; };
export const getMode = (): Mode => {
const win = window as any;
const config = win && win.Ionic && win.Ionic.config;
if (config) {
if (config.mode) {
return config.mode;
} else {
return config.get('mode');
}
}
return 'md';
};