Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change name of data to firebase
  • Loading branch information
fej-snikduj committed Oct 24, 2017
commit 488fd9321b95ffb3cf562f7a709e2dfae40312b8
12 changes: 4 additions & 8 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,16 @@ import { getDotStrPath } from './reducer'
* todos: getValueAt(firebase, 'data/todos/user1', defaultValue)
* })
*/
export const getValueAt = (data, path, notSetValue) => {
if (!data) {
export const getValueAt = (firebase, path, notSetValue) => {
if (!firebase) {
return notSetValue
}

const pathArr = `/${fixPath(path)}`.split(/\//).slice(1)
const dotPath = getDotStrPath(pathArr)
const valueAtPath = get(data, dotPath)
const valueAtPath = get(firebase, dotPath)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have the notSetValue be passed here so it is used as the defaultValue:

return get(firebase, dotPath, notSetValue)


if (has(data, dotPath)) {
return get(data, dotPath)
}

return data
return valueAtPath
}

/**
Expand Down