function unsetWatcher(firebase, dispatch, event, path, queryId) {
  const id =
    queryId || getQueryIdFromPath(path, event) || getWatchPath(event, path)
  path = path.split('#')[0]
  const { watchers } = firebase._
  if (watchers[id] <= 1) {
    delete watchers[id]
    if (event !== 'first_child' && event !== 'once') {
      firebase.database().ref().child(path).off(event)
    }
  } else if (watchers[id]) {
    watchers[id]--
  }

  dispatch({ type: actionTypes.UNSET_LISTENER, path, payload: { id } })
}
@private
@param {object} firebase - Internal firebase object
@param {Function} dispatch - Redux's dispatch function
@param {string} event - Type of event to watch for
@param {string} path - Path to watch with watcher
@param {string} queryId - Id of query