Skip to content

Instantly share code, notes, and snippets.

@ltk
Created February 2, 2016 21:51
Show Gist options
  • Save ltk/ba19abf0bb9dfe5eafe6 to your computer and use it in GitHub Desktop.
Save ltk/ba19abf0bb9dfe5eafe6 to your computer and use it in GitHub Desktop.
BaaS at Scale | Update Subscription Granularity
// Method 1: High Data Usage
// =========================
const rootReference = new Firebase(firebaseUrl)
const itemsReference = rootReference.child('items')
itemsReference.on('value', function(data) {
// Update the UI with the items update
})
// Method 2: Low Data Usage
// ========================
const rootReference = new Firebase(firebaseUrl)
const itemIds = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r"]
itemIds.forEach((itemId) => {
const itemReference = rootReference.child(`items/${itemId}`)
itemReference.on('value', function(data) {
// Update the UI with the item update
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment