-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b3c14b
commit c87f0c5
Showing
4 changed files
with
56 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Config as CoreConfig } from '@ionic/core'; | ||
|
||
export class Config { | ||
|
||
constructor(defaultConfig: {[key: string]: any}) { | ||
const Ionic = (window as any).Ionic; | ||
if (Ionic.config && Ionic.config.constructor.name !== 'Object') { | ||
console.error('ionic config was already initialized'); | ||
return; | ||
} | ||
Ionic.config = { | ||
...Ionic.config, | ||
...defaultConfig | ||
}; | ||
} | ||
|
||
get(key: string, fallback?: any): any { | ||
return getConfig().get(key, fallback); | ||
} | ||
|
||
getBoolean(key: string, fallback?: boolean): boolean { | ||
return getConfig().getBoolean(key, fallback); | ||
} | ||
|
||
getNumber(key: string, fallback?: number): number { | ||
return getConfig().getNumber(key, fallback); | ||
} | ||
|
||
set(key: string, value?: any) { | ||
getConfig().set(key, value); | ||
} | ||
} | ||
|
||
function getConfig(): CoreConfig { | ||
const Ionic = (window as any).Ionic; | ||
if (Ionic && Ionic.config) { | ||
return Ionic.config; | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters