Skip to content

Commit d5e021b

Browse files
committed
chore(example): add toggle button to check leaks
1 parent db90cb0 commit d5e021b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

examples/index.html

+17-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
-->
2727

2828
<div id="app">
29+
<button @click="toggleTodos">Toggle todos</button>
30+
<br/>
2931
<input
3032
v-model.trim="newTodoText"
3133
@keyup.enter="addTodo"
@@ -55,7 +57,9 @@
5557
databaseURL: 'https://vue-fire-store.firebaseio.com'
5658
})
5759
const db = firebase.firestore()
58-
var todos = db.collection('todos')
60+
const todos = db.collection('todos')
61+
const unFinishedTodos = todos.where('finished', '==', false)
62+
const finishedTodos = todos.where('finished', '==', true)
5963
const config = db.collection('configs').doc('jORwjIykFo2NmkdzTkhU')
6064

6165
new Vue({
@@ -65,10 +69,12 @@
6569
config: null,
6670
newTodoText: ''
6771
},
72+
6873
firestore: {
69-
todos: todos.where('finished', '==', false),
74+
todos: unFinishedTodos,
7075
config
7176
},
77+
7278
methods: {
7379
addTodo: function () {
7480
if (this.newTodoText) {
@@ -85,6 +91,15 @@
8591
},
8692
removeTodo: function (todo) {
8793
todos.doc(todo.id).delete()
94+
},
95+
toggleTodos () {
96+
console.log(this.$firestoreRefs.todos === unFinishedTodos)
97+
this.$bind(
98+
'todos',
99+
this.$firestoreRefs.todos === unFinishedTodos
100+
? finishedTodos
101+
: unFinishedTodos
102+
)
88103
}
89104
}
90105
})

0 commit comments

Comments
 (0)