Skip to content

Commit c1a0445

Browse files
authored
#4 Once and Populate Bufixes
* fixes #2 (`once` not function) * fixes #3 (multiple populations)
2 parents b0e9d03 + b9b89c7 commit c1a0445

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/actions/query.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ export const watchEvent = (firebase, dispatch, event, path, dest, onlyLastEvent
197197
}
198198

199199
const runQuery = (q, e, p, params) => {
200+
if (e === 'once') {
201+
q.once('value').then(snapshot => dispatch({type: SET, path, data: snapshot.val()}))
202+
return;
203+
}
204+
200205
q.on(e, snapshot => {
201206
let data = (e === 'child_removed') ? undefined : snapshot.val()
202207
const resultPath = dest || (e === 'value') ? p : p + '/' + snapshot.key
@@ -208,7 +213,7 @@ export const watchEvent = (firebase, dispatch, event, path, dest, onlyLastEvent
208213
}
209214
}
210215

211-
const populates = filter(params, (param) => params.indexOf('populate'))
216+
const populates = filter(params, (param) => params.indexOf('populate') > -1)
212217
.map(p => p.split('=')[1])
213218

214219
// Dispatch standard if no populates

0 commit comments

Comments
 (0)