Skip to content

Commit

Permalink
add default value for remote config service
Browse files Browse the repository at this point in the history
  • Loading branch information
fachrihawari committed Oct 21, 2019
1 parent f6523d6 commit c636ddc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ modules: [
useOnly: ['auth','firestore','functions','storage','realtimeDb', 'messaging', 'performance', 'analytics', 'remoteConfig'],
customEnv: false,
functionsLocation: 'us-central1',
remoteConfig: {
settings: {
fetchTimeoutMillis: 60000,
minimumFetchIntervalMillis: 43200000,
},
defaultConfig: {
'welcome_message': 'Welcome'
}
}
}
]
],
Expand Down Expand Up @@ -212,6 +221,20 @@ You can change the location with this option.

More information [here](https://firebase.google.com/docs/functions/locations).

#### remoteConfig
You can custom the settings and default config.
```js
{
settings: {
fetchTimeoutMillis: 60000,
minimumFetchIntervalMillis: 43200000,
},
defaultConfig: {
'welcome_message': 'Welcome' // you can add another default config here
}
}
```

## Examples

Check out our [Demo](https://nuxt-fire-demo.firebaseapp.com/) or its [GitHub Repo](https://github.com/lupas/nuxt-fire-demo) for example code.
Expand Down
13 changes: 13 additions & 0 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ export default async (ctx, inject) => {

const fireConfig = firebase.remoteConfig()
const fireConfigObj = firebase.remoteConfig

if (options.remoteConfig) {
const { settings: remoteSettings, defaultConfig: remoteDefaultConfig } = options.remoteConfig
if (remoteSettings) {
const { minimumFetchIntervalMillis, fetchTimeoutMillis } = remoteSettings
fireConfig.settings = {
fetchTimeoutMillis: fetchTimeoutMillis ? fetchTimeoutMillis : 60000,
minimumFetchIntervalMillis: minimumFetchIntervalMillis ? minimumFetchIntervalMillis : 43200000
}
}
fireConfig.defaultConfig = (remoteDefaultConfig)
}

inject('fireConfig', fireConfig)
inject('fireConfigObj', fireConfigObj)
}
Expand Down

0 comments on commit c636ddc

Please sign in to comment.