Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion angular/src/providers/config.ts
Expand Up @@ -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);
Expand All @@ -44,7 +45,7 @@ export const ConfigToken = new InjectionToken<any>('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;
}
Expand Down
13 changes: 13 additions & 0 deletions core/src/utils/config.ts
Expand Up @@ -199,3 +199,16 @@ export const setupConfig = (config: IonicConfig) => {
};
return win.Ionic.config;
};

export const getMode = (): Mode => {
const win = window as any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be IonicWindow as well?

const config = win && win.Ionic && win.Ionic.config;
if (config) {
if (config.mode) {
return config.mode;
} else {
return config.get('mode');
}
}
return 'md';
};