Skip to content
This repository has been archived by the owner on May 2, 2020. It is now read-only.

Commit

Permalink
closes #683
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptPilot authored and scriptPilot committed Oct 27, 2017
1 parent 2b8d434 commit dfc2ca0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

- [x] [#572 - Rename database-rules.json to firebase-database.json](https://github.com/scriptPilot/app-framework/issues/572)
- [x] [#573 - Rename storage-rules.txt to firebase-storage.txt](https://github.com/scriptPilot/app-framework/issues/573)
- [x] [#683 - Make Firebase shortlink available in each component](https://github.com/scriptPilot/app-framework/issues/683) ([read the docs](https://github.com/scriptPilot/app-framework/blob/master/docs/firebase.md))

## Version 1.15.0

Expand Down
20 changes: 20 additions & 0 deletions client/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,25 @@ let easierLanguagePattern = {
}
}
}
let easierFirebase = {
computed: {
// Authentication
$fireAuth() {
return window.firebase && window.firebase.auth ? window.firebase.auth : null
},
$user() {
return this.$root.user
},
// Realtime Database
$fireDB() {
return window.firebase && window.firebase.database ? (ref) => { return window.firebase.database().ref(ref) } : null
},
// Cloud Storage
$fireStore() {
return window.firebase && window.firebase.storage ? (ref) => { return window.firebase.storage().ref(ref) } : null
},
}
}

let mixins = {}
mixins.loadConfig = {
Expand Down Expand Up @@ -1207,6 +1226,7 @@ function initF7VueApp () {
// Use global mixins
vue.mixin(easierGlobalDataObject)
vue.mixin(easierLanguagePattern)
vue.mixin(easierFirebase)
if (config.restoreComponentData) {
vue.mixin(manageComponentData)
}
Expand Down
9 changes: 4 additions & 5 deletions docs/firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ Disabling a service will reduce the build size.

You can use Firebase in any Vue hook `created` or later:

- `window.firebase` - Firebase application instance
- `this.$root.user` or window.user - Null or object (uid, email, name, photo)
- `this.$root.db(...)` or `window.db(...)` - Shortlink to `window.firebase.database().ref(...)`
- `this.$root.store(...)` or `window.store(...)` - Shortlink to `window.firebase.storage().ref(...)`
- `this.$root.timestamp` or `window.timestamp` - Shortlink to `window.database.ServerValue.TIMESTAMP`
- `this.$fireAuth` - Shortlink to `window.firebase.auth`
- `this.$user`- Null or object (uid, email, name, photo)
- `this.$fireDB` - Shortlink to `window.firebase.database().ref`
- `this.$fireStore` - Shortlink to `window.firebase.storage().ref`

To test your Firebase rules in development, you have the chance to configure a devFirebase project:

Expand Down

0 comments on commit dfc2ca0

Please sign in to comment.