Skip to content

Commit

Permalink
Add connect enhancer
Browse files Browse the repository at this point in the history
  • Loading branch information
migueloller committed Jun 27, 2016
1 parent 8b2843a commit 1c8d940
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/components/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ function tryCatch(fn, ctx) {
// Helps track hot reloading.
let nextVersion = 0

export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
export default function connect(...args) {
const [ mapStateToProps, mapDispatchToProps, mergeProps, { enhancer, ...options } = {} ] = args

if (typeof enhancer !== 'undefined') {
if (typeof enhancer !== 'function') {
throw new Error('Expected the enhancer to be a function.')
}

return enhancer(connect)(...args.slice(0, args.length - 1), options)
}

const shouldSubscribe = Boolean(mapStateToProps)
const mapState = mapStateToProps || defaultMapStateToProps

Expand Down

0 comments on commit 1c8d940

Please sign in to comment.