Skip to content

Commit

Permalink
Version v1.4.3 (#171)
Browse files Browse the repository at this point in the history
* `onAuthStateChange` added to config validation
* deprecation warning added for `config.distpatchOnUnsetListener`
  • Loading branch information
prescottprue authored Jun 25, 2017
1 parent fc133ca commit 0ad5b10
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-redux-firebase",
"version": "1.4.2",
"version": "1.4.3",
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
"browser": "dist/react-redux-firebase.js",
"main": "lib/index.js",
Expand Down
4 changes: 3 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ export const validateConfig = (config) => {
// Check that some certain config are functions if they exist
const functionProps = [
'fileMetadataFactory',
'profileDecorator'
'profileDecorator',
'onAuthStateChange'
]

functionProps.forEach((p) => {
if (!!config[p] && !isFunction(config[p])) {
throw new Error(`${p} parameter in react-redux-firebase config must be a function. check your compose function.`)
Expand Down
8 changes: 6 additions & 2 deletions src/utils/query.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { actionTypes } from '../constants'
import { isNaN } from 'lodash'
import { isNaN, isFunction } from 'lodash'

const { UNSET_LISTENER } = actionTypes

Expand Down Expand Up @@ -100,7 +100,11 @@ export const unsetWatcher = (firebase, dispatch, event, path, queryId = undefine
delete firebase._.watchers[id]
if (event !== 'first_child' && event !== 'once') {
firebase.database().ref().child(path).off(event)
if (firebase._.config.distpatchOnUnsetListener) {
const { config } = firebase._
if (config.dispatchOnUnsetListener || config.distpatchOnUnsetListener) {
if (config.distpatchOnUnsetListener && isFunction(console.warn)) { // eslint-disable-line no-console
console.warn('config.distpatchOnUnsetListener is Depreceated and will be removed in future versions. Please use config.dispatchOnUnsetListener (dispatch spelled correctly).') // eslint-disable-line no-console
}
dispatch({ type: UNSET_LISTENER, path })
}
}
Expand Down

0 comments on commit 0ad5b10

Please sign in to comment.