Skip to content

Commit 195ea7d

Browse files
DaBsposva
authored andcommitted
Enabled firebase to be called as function, thus enabling patterns where Firebase ref's are stored in root component (#25)
* Enabled firebase to be called as function * Added basic test case for ability to run as function * Deleted compiled files * Revert "Deleted compiled files" This reverts commit 327203a. * Revert "Revert "Deleted compiled files"" This reverts commit a11bedd. * Revert "Deleted compiled files" This reverts commit 327203a. * Changes to test spec * Updated test to be more simple * Removed regex from throw, added Sinon spy to call * Changed line order of check * Moved the correct line :P * Reverted changes to dist files
1 parent 802c224 commit 195ea7d

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: src/vuefire.js

+1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ function ensureRefs (vm) {
213213

214214
var init = function () {
215215
var bindings = this.$options.firebase
216+
if (typeof bindings === 'function') bindings = bindings.call(this)
216217
if (!bindings) return
217218
ensureRefs(this)
218219
for (var key in bindings) {

Diff for: tests/vuefire.spec.js

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ describe('VueFire', function () {
2525
})
2626
})
2727

28+
describe('support Function options', function () {
29+
it('option is callable as function', function (done) {
30+
var spy = sinon.spy()
31+
expect(function () {
32+
new Vue({
33+
firebase: spy
34+
}).$mount()
35+
}).to.not.throw()
36+
expect(spy.calledOnce).to.be.true
37+
done()
38+
})
39+
})
40+
2841
describe('bind as Array', function () {
2942
it('throws error for invalid firebase ref', function () {
3043
helpers.invalidFirebaseRefs.forEach(function (ref) {

0 commit comments

Comments
 (0)