Skip to content

Commit 0263b0b

Browse files
authored
Version v1.1.5 (#30)
* `ref` is now a function in compose (Addresses #28) * test added to confirm that `ref` is exposed correctly * Peer Dependencies updated to include `react-redux` `^5.0.0` and ` redux` `^3.6.0`
1 parent 493a034 commit 0263b0b

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "1.1.4",
3+
"version": "1.1.5",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
55
"main": "dist/index.js",
66
"module": "src/index.js",
@@ -53,8 +53,8 @@
5353
},
5454
"peerDependencies": {
5555
"react": "^0.14.6 || ^15.0.0",
56-
"react-redux": "^4.0.6",
57-
"redux": "^3.0.5"
56+
"react-redux": "^4.0.6 || ^5.0.0",
57+
"redux": "^3.0.5 || ^3.6.0"
5858
},
5959
"devDependencies": {
6060
"babel-cli": "^6.18.0",

src/compose.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export default (config, otherConfig) => next =>
7474
Firebase.database.enableLogging(configs.enableLogging)
7575
}
7676

77-
const ref = Firebase.database().ref()
77+
const rootRef = Firebase.database().ref()
7878

7979
const firebase = Object.defineProperty(Firebase, '_', {
8080
value: {
@@ -88,16 +88,16 @@ export default (config, otherConfig) => next =>
8888
})
8989

9090
const set = (path, value, onComplete) =>
91-
ref.child(path).set(value, onComplete)
91+
rootRef.child(path).set(value, onComplete)
9292

9393
const push = (path, value, onComplete) =>
94-
ref.child(path).push(value, onComplete)
94+
rootRef.child(path).push(value, onComplete)
9595

9696
const update = (path, value, onComplete) =>
97-
ref.child(path).update(value, onComplete)
97+
rootRef.child(path).update(value, onComplete)
9898

9999
const remove = (path, onComplete) =>
100-
ref.child(path).remove(onComplete)
100+
rootRef.child(path).remove(onComplete)
101101

102102
const uploadFile = (path, file, dbPath) =>
103103
storageActions.uploadFile(dispatch, firebase, { path, file, dbPath })
@@ -109,15 +109,15 @@ export default (config, otherConfig) => next =>
109109
storageActions.deleteFile(dispatch, firebase, { path, dbPath })
110110

111111
const uniqueSet = (path, value, onComplete) =>
112-
ref.child(path)
112+
rootRef.child(path)
113113
.once('value')
114114
.then(snap => {
115115
if (snap.val && snap.val() !== null) {
116116
const err = new Error('Path already exists.')
117117
if (onComplete) onComplete(err)
118118
return Promise.reject(err)
119119
}
120-
return ref.child(path).set(value, onComplete)
120+
return rootRef.child(path).set(value, onComplete)
121121
})
122122

123123
const watchEvent = (type, path) =>
@@ -139,7 +139,7 @@ export default (config, otherConfig) => next =>
139139
authActions.resetPassword(dispatch, firebase, credentials)
140140

141141
firebase.helpers = {
142-
ref: Firebase.database().ref,
142+
ref: path => Firebase.database().ref(path),
143143
set,
144144
uniqueSet,
145145
push,

test/unit/compose.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ describe('Compose', () => {
2424
})
2525

2626
describe('helpers', () => {
27+
describe('ref', () => {
28+
it('exists', () => {
29+
expect(helpers.ref('test')).to.be.an.object
30+
})
31+
it('has child', () => {
32+
expect(helpers.ref('test').child('asdf')).to.be.an.object
33+
})
34+
})
35+
2736
describe('set', () =>
2837
helpers.set('test', {some: 'asdf'})
2938
)

0 commit comments

Comments
 (0)