Skip to content
1 change: 1 addition & 0 deletions dist/vuefire.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ return /******/ (function(modules) { // webpackBootstrap
var init = function () {
var bindings = this.$options.firebase
if (!bindings) return
if (typeof bindings === 'function') bindings = bindings.call(this)
ensureRefs(this)
for (var key in bindings) {
bind(this, key, bindings[key])
Expand Down
2 changes: 1 addition & 1 deletion dist/vuefire.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/vuefire.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ function ensureRefs (vm) {
var init = function () {
var bindings = this.$options.firebase
if (!bindings) return
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to move this one line below, so if the function is returning nothing we can skip too

if (typeof bindings === 'function') bindings = bindings.call(this)
ensureRefs(this)
for (var key in bindings) {
bind(this, key, bindings[key])
Expand Down
13 changes: 13 additions & 0 deletions tests/vuefire.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ describe('VueFire', function () {
})
})

describe('support Function options', function () {
it('option is callable as function', function (done) {
var spy = sinon.spy()
expect(function () {
new Vue({
firebase: spy
}).$mount()
}).to.not.throw()
expect(spy.calledOnce).to.be.true
done()
})
})

describe('bind as Array', function () {
it('throws error for invalid firebase ref', function () {
helpers.invalidFirebaseRefs.forEach(function (ref) {
Expand Down