Skip to content

Commit d7a90ee

Browse files
committed
feat(refs): add $firestoreRefs
1 parent e6716e1 commit d7a90ee

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function install (Vue, options) {
8989
created () {
9090
const { firestore } = this.$options
9191
this._firestoreUnbinds = Object.create(null)
92+
this.$firestoreRefs = Object.create(null)
9293
if (!firestore) return
9394
Object.keys(firestore).forEach(key => {
9495
this.$bind(key, firestore[key])
@@ -110,6 +111,7 @@ function install (Vue, options) {
110111
key,
111112
ref,
112113
})
114+
this.$firestoreRefs[key] = ref
113115
}
114116

115117
Vue.prototype.$unbind = function (key) {

test/index.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,10 @@ test('setups _firestoreUnbinds with no firestore options', t => {
5656
t.truthy(vm._firestoreUnbinds)
5757
t.deepEqual(Object.keys(vm._firestoreUnbinds), [])
5858
})
59+
60+
test('setups _firestoreRefs', t => {
61+
const vm = t.context.vm
62+
t.deepEqual(Object.keys(vm.$firestoreRefs).sort(), ['item', 'items'])
63+
t.is(vm.$firestoreRefs.item, t.context.document)
64+
t.is(vm.$firestoreRefs.items, t.context.collection)
65+
})

0 commit comments

Comments
 (0)