R
R
RaulDuke2017-04-27 07:25:55
JavaScript
RaulDuke, 2017-04-27 07:25:55

Tell us about the best practices for using Firebase.database?

Hello everyone,
recently I asked a question about changing the framework and the guys advised me vue - taking the opportunity to thank you again, it's just a miracle!
After a while, when I more or less got used to it, I became interested in whether I was using firebase correctly. The question is, from each component that needs to get data from the database, I will import db.js:

//db.js
import Vue from 'vue'
import VueFire from 'vuefire'
import Firebase from 'firebase'

Vue.use(VueFire)

export default Firebase.initializeApp({
    apiKey: '...',
    authDomain: '....',
    databaseURL: '...',
    projectId: '...',
    storageBucket: '....',
    messagingSenderId: '...'
  });

And after that, in the component, I already make the selections I need firebase.database().ref('users').child(id).bla-bla. And I began to be disturbed by an obsessive thought, but isn’t this an anti-pattern for an hour? Maybe it's worth once to initialize the firebase from the main vue instance and try to invent something like a singleton through props. Or some other patterns.
Please tell us how you work with firebase and what practices do you recommend? Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question