When calling firedux.update( path/to/item, data)
it updates the data correctly in Firebase by merging it with the current data.
However, the new Redux state for firedux.data.path.to.item
is created in the same way as for the set()
command. That leads to a state that has only the updated value not the ones it was merged with.
Example:
Redux state before:
item: {
title: 'Before I was named this',
content: 'Some text as the content',
data: '2016-01-01'
}
Redux state after calling firedux.update('item', { title: 'Some new title', checked: true })
:
item: {
title: 'Some new title',
checked: true
}
After looking at the source code of Firedux, I suppose the reason is that the reducer
function calls makeFirebaseState(action, state, action.path, action.value)
for both FIREBASE_SET
and FIREBASE_UPDATE
.
Instead for FIREBASE_UPDATE
it should call makeFirebaseState(action, state, action.path, action.snapshot.val())
(the same as FIREBASE_WATCH
).
Please correct me, if I am wrong here :)