From 0f05ea424591900ce0695baeff5ae86d42d3b047 Mon Sep 17 00:00:00 2001 From: Manu MA Date: Wed, 25 Sep 2019 17:21:43 +0200 Subject: [PATCH] feat(config): expose getMode() and deprecate Config (#19104) --- angular/src/providers/config.ts | 3 ++- core/src/utils/config.ts | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/angular/src/providers/config.ts b/angular/src/providers/config.ts index fa41a40fbb8..541b32e1938 100644 --- a/angular/src/providers/config.ts +++ b/angular/src/providers/config.ts @@ -33,6 +33,7 @@ export class Config { } 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(); if (c) { c.set(key, value); @@ -44,7 +45,7 @@ export const ConfigToken = new InjectionToken('USERCONFIG'); const getConfig = (): CoreConfig | null => { if (typeof (window as any) !== 'undefined') { - const Ionic = (window as IonicWindow).Ionic; + const Ionic = (window as any as IonicWindow).Ionic; if (Ionic && Ionic.config) { return Ionic.config; } diff --git a/core/src/utils/config.ts b/core/src/utils/config.ts index d4c971b9e8c..4fcb15e6e4b 100644 --- a/core/src/utils/config.ts +++ b/core/src/utils/config.ts @@ -199,3 +199,16 @@ export const setupConfig = (config: IonicConfig) => { }; 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'; +};