diff --git a/src/driver/connect.ts b/src/driver/connect.ts
index 3ea1ba4..001cae0 100644
--- a/src/driver/connect.ts
+++ b/src/driver/connect.ts
@@ -68,6 +68,14 @@ function link
(instance: React.Component
, sources: Sources): WrappedM
}
const map = new Map(/* sources.creator -> wrappedMethods.method */)
+ const dispatchCall: TriggerOtherMethod = (createMethod, ...otherArgs) => {
+ const isFromSource = sourcesValues.includes(createMethod)
+ if (isFromSource) {
+ const method = map.get(createMethod)
+ const runnable = applyMiddlewares(method, otherArgs)
+ run(runnable)
+ }
+ }
const dispatchState: DispatchState = (updater, callback) => {
instance.setState(updater, callback)
}
@@ -75,14 +83,7 @@ function link
(instance: React.Component
, sources: Sources): WrappedM
updater(instance.props, instance.state)
}
const dispatch: Dispatch
= {
- call(createMethod: MethodCreator, ...otherArgs: ParametersOfReturnedFunction) {
- const isFromSource = sourcesValues.includes(createMethod)
- if (isFromSource) {
- const method = map.get(createMethod)
- const runnable = applyMiddlewares(method, otherArgs)
- run(runnable)
- }
- },
+ call: dispatchCall,
get: prepareState,
set: dispatchState,
}
@@ -103,14 +104,14 @@ export default function connect(mapping: Sources) {
ComponentClass: React.ComponentClass
): React.ComponentClass {
return class AwesomeApp extends React.PureComponent {
- static displayName = `Connected(${ComponentClass.name})`
+ static displayName = `Connected(${ComponentClass.displayName || ComponentClass.name})`
static defaultProps = ComponentClass.defaultProps
state = {} as ExtraP
- boundCore = link(this, mapping) as WrappedMethods
+ connectedMethods = link(this, mapping) as WrappedMethods
render() {
- const props = Object.assign({}, this.props, this.boundCore, this.state)
+ const props = Object.assign({}, this.props, this.connectedMethods, this.state)
return React.createElement(ComponentClass, props)
}
}