20.04 Read Data - When Task Added
This commit is contained in:
parent
b86f2bc0cf
commit
7378e2391a
@ -1,6 +1,6 @@
|
||||
import Vue from 'vue'
|
||||
import { uid } from 'quasar'
|
||||
import { databaseDb } from 'boot/firebase'
|
||||
import { firebaseDb, firebaseAuth } from 'boot/firebase'
|
||||
|
||||
const state = {
|
||||
tasks: {
|
||||
@ -69,7 +69,18 @@ const actions = {
|
||||
commit('setSort', value)
|
||||
},
|
||||
fbReadData ({ commit }) {
|
||||
console.log('read data from database')
|
||||
const userId = firebaseAuth.currentUser.uid
|
||||
const userTasks = firebaseDb.ref('tasks/' + userId)
|
||||
|
||||
// child added
|
||||
userTasks.on('child_added', snapshot => {
|
||||
const task = snapshot.val()
|
||||
const payload = {
|
||||
id: snapshot.key,
|
||||
task: task
|
||||
}
|
||||
commit('addTask', payload)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user