Skip to content
Merged
Changes from all commits
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
Allow to use different stores in firebaseConnect
It helps to use more than one firebase app by creating separate store for each one,
it may be enough to fix #29
  • Loading branch information
martynovs authored May 31, 2017
commit 4faf5316a4ea787ccfb1baa7e7394ec3230c2c6e
8 changes: 5 additions & 3 deletions src/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { getEventsFromInput, createCallable } from './utils'
* auth: pathToJS(firebase, 'auth') // pass auth data as this.props.auth
* }))(fbWrapped)
*/
export default (dataOrFn = []) => WrappedComponent => {
export const createFirebaseConnect = (storeKey = 'store') => (dataOrFn = []) => WrappedComponent => {
class FirebaseConnect extends Component {
constructor (props, context) {
super(props, context)
Expand All @@ -40,11 +40,11 @@ export default (dataOrFn = []) => WrappedComponent => {
}

static contextTypes = {
store: PropTypes.object.isRequired
[storeKey]: PropTypes.object.isRequired
};

componentWillMount () {
const { firebase, dispatch } = this.context.store
const { firebase, dispatch } = this.context[storeKey]

// Allow function to be passed
const inputAsFunc = createCallable(dataOrFn)
Expand Down Expand Up @@ -93,3 +93,5 @@ export default (dataOrFn = []) => WrappedComponent => {

return hoistStatics(FirebaseConnect, WrappedComponent)
}

export default createFirebaseConnect()