Skip to content

Commit 0f05ea4

Browse files
authored
feat(config): expose getMode() and deprecate Config (ionic-team#19104)
1 parent bfa17d1 commit 0f05ea4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

angular/src/providers/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export class Config {
3333
}
3434

3535
set(key: keyof IonicConfig, value?: any) {
36+
console.warn(`[DEPRECATION][Config]: The Config.set() method is deprecated and will be removed in the next major release.`);
3637
const c = getConfig();
3738
if (c) {
3839
c.set(key, value);
@@ -44,7 +45,7 @@ export const ConfigToken = new InjectionToken<any>('USERCONFIG');
4445

4546
const getConfig = (): CoreConfig | null => {
4647
if (typeof (window as any) !== 'undefined') {
47-
const Ionic = (window as IonicWindow).Ionic;
48+
const Ionic = (window as any as IonicWindow).Ionic;
4849
if (Ionic && Ionic.config) {
4950
return Ionic.config;
5051
}

core/src/utils/config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,16 @@ export const setupConfig = (config: IonicConfig) => {
199199
};
200200
return win.Ionic.config;
201201
};
202+
203+
export const getMode = (): Mode => {
204+
const win = window as any;
205+
const config = win && win.Ionic && win.Ionic.config;
206+
if (config) {
207+
if (config.mode) {
208+
return config.mode;
209+
} else {
210+
return config.get('mode');
211+
}
212+
}
213+
return 'md';
214+
};

0 commit comments

Comments
 (0)