re-reduced
Advanced tools
Comparing version 0.7.11 to 0.7.12
import { InferableComponentEnhancerWithProps, MapStateToProps } from "react-redux"; | ||
import { Dispatch } from "redux"; | ||
import { ActionCreator } from "./core"; | ||
@@ -6,5 +7,12 @@ import { Tree } from "./helpers/objects"; | ||
export interface ConnectWithActions { | ||
<TProps = {}, TOwnProps = {}, TActions extends Tree<ActionCreator<any>> = {}>(actions: TActions): InferableComponentEnhancerWithProps<TProps, TOwnProps>; | ||
<TProps = {}, TOwnProps = {}, TState = {}, TActions extends Tree<ActionCreator<any>> = {}>(actions: TActions, mapStateToProps: MapStateToProps<Partial<TProps>, TOwnProps, TState>): InferableComponentEnhancerWithProps<TProps, {}>; | ||
<TProps extends { | ||
actions: TActions; | ||
}, TOwnProps = {}, TActions extends Tree<ActionCreator<any>> = {}>(actions: TActions): InferableComponentEnhancerWithProps<TProps, TOwnProps>; | ||
<TProps extends { | ||
actions: TActions; | ||
}, TOwnProps = {}, TState = {}, TActions extends Tree<ActionCreator<any>> = {}>(actions: TActions, mapStateToProps: MapStateToProps<Partial<TProps>, TOwnProps, TState>): InferableComponentEnhancerWithProps<TProps, {}>; | ||
} | ||
export declare const bindActionCreators: <TActions extends Tree<ActionCreator<any>>>(actions: TActions) => (dispatch: Dispatch<import("redux").AnyAction>) => { | ||
actions: TActions; | ||
}; | ||
/** | ||
@@ -11,0 +19,0 @@ * connectWithActions |
@@ -7,2 +7,5 @@ "use strict"; | ||
const toDispatcher = (dispatch) => (action) => redux_1.compose(dispatch, action); | ||
exports.bindActionCreators = (actions) => (dispatch) => ({ | ||
actions: objects_1.transformTree(toDispatcher(dispatch), actions) | ||
}); | ||
/** | ||
@@ -17,6 +20,3 @@ * connectWithActions | ||
exports.connectWithActions = (actions, mapStateToProps) => { | ||
const mapDisptachToProps = (dispatch) => ({ | ||
actions: objects_1.transformTree(toDispatcher(dispatch), actions) | ||
}); | ||
return react_redux_1.connect(mapStateToProps, mapDisptachToProps); | ||
return react_redux_1.connect(mapStateToProps, exports.bindActionCreators(actions)); | ||
}; |
{ | ||
"name": "re-reduced", | ||
"version": "0.7.11", | ||
"version": "0.7.12", | ||
"description": "A utility toolbelt that reduces boilerplate from your react/redux app", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
32757
292