posva / vuexfire

Check
https://github.com/vuejs/vuefire
MIT License
558 stars 49 forks source link

Mutate state with .value directly. #178

Closed Plinpod closed 6 years ago

Plinpod commented 6 years ago

Hello,

I just at started using vuexfire and was wondering if it's possible to map the .value inside the returned firebase object to the state directly. Currently I have an initial state like this

state: {
  active: false
}

After I setup vuexfire and bindFirebaseRef it works and gets my active value from firebase and makes the state this bindFirebaseRef('active', db.ref('state').child('active')

state: {
  active: {
     .key: "active",
     .value: true
  }
}

I would like it to make it to map .value directly to the active property in the state like so

state: {
  active: true
}

Hope that makes sense. Thanks!

posva commented 6 years ago

This is unfortunately not possible when targetting a child property. If you target directly the state from your firebase database, you can bind that onto a property and you will have { active: true }