Skip to content

Enabled firebase to be called as function, thus enabling patterns where Firebase ref's are stored in root component #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 9, 2016
Merged
1 change: 1 addition & 0 deletions src/vuefire.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ function ensureRefs (vm) {

var init = function () {
var bindings = this.$options.firebase
if (typeof bindings === 'function') bindings = bindings.call(this)
if (!bindings) return
ensureRefs(this)
for (var key in bindings) {
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