Skip to content

Commit b8faabe

Browse files
committed
switch to bind as array by default
1 parent 6e90db8 commit b8faabe

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@
1818
var vm = new Vue({
1919
el: '#demo',
2020
firebase: {
21-
// simple syntax, bind as an object
22-
anObject: new Firebase('url/to/my/object'),
21+
// simple syntax, bind as an array by default
22+
anArray: new Firebase('url/to/my/collection'),
23+
// can also bind to a query
24+
// anArray: new Firebase('url/to/my/collection').limitToLast(25)
2325
// full syntax
24-
anArray: {
25-
// the source can be either a ref or a query
26-
source: new Firebase('url/to/my/list').limitToLast(25),
27-
// bind as an array
28-
asArray: true,
26+
anObject: {
27+
source: new Firebase('url/to/my/object'),
28+
// optionally bind as an object
29+
asObject: true,
2930
// optionally provide the cancelCallback
3031
cancelCallback: function () {}
3132
}
@@ -37,7 +38,7 @@ var vm = new Vue({
3738
<div id="demo">
3839
<pre>{{ anObject | json }}</pre>
3940
<ul>
40-
<li v-for="item in anArray">{{ item.text }}</li>
41+
<li v-for="item in items">{{ item.text }}</li>
4142
</ul>
4243
</div>
4344
```

src/vuefire.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ function bind (vm, key, source) {
5252
if (!isObject(source)) {
5353
throw new Error('VueFire: invalid Firebase binding source.')
5454
}
55-
var asArray = false
55+
var asObject = false
5656
var cancelCallback = null
5757
// check { source, asArray, cancelCallback } syntax
5858
if (isObject(source.source)) {
59-
asArray = source.asArray
59+
asObject = source.asObject
6060
cancelCallback = source.cancelCallback
6161
source = source.source
6262
}
@@ -68,10 +68,10 @@ function bind (vm, key, source) {
6868
vm.$firebaseRefs[key] = ref
6969
vm._firebaseSources[key] = source
7070
// bind based on initial value type
71-
if (asArray) {
72-
bindAsArray(vm, key, source, cancelCallback)
73-
} else {
71+
if (asObject) {
7472
bindAsObject(vm, key, source, cancelCallback)
73+
} else {
74+
bindAsArray(vm, key, source, cancelCallback)
7575
}
7676
}
7777

0 commit comments

Comments
 (0)