Hey, I am working on a Kotlin fullstack applicatio...
# redux
m
Hey, I am working on a Kotlin fullstack application, and am using redux along with my react components. The issue I'm having is that I cannot figure out how to map multiple actions to one component. For example in the following code, I have the
UploadFilesButtonDispatchProps
, which contains two callbacks in it's props that are meant to map to actions (
uploadFile
and
toggleUploadInProgress
), but I can only dispatch one of the actions, as the
rConntect<...>
definition only takes in one action.
Copy code
private interface UploadFilesButtonStateProps : RProps { }

private interface UploadFilesButtonDispatchProps : RProps {
    var uploadFile: (FileInfo) -> Unit
    var toggleUploadInProgress: (Boolean) -> Unit
}

val uploadFilesButton: RClass<RProps> =
    rConnect<AppState, UploadFile, WrapperAction, RProps, UploadFilesButtonStateProps, UploadFilesButtonDispatchProps, UploadFilesButtonProps>(
        { state, _ ->
        },
        { dispatch, _ ->
            uploadFile = { dispatch(UploadFile(it)) }
        }
    )(UploadFilesButton::class.js.unsafeCast<RClass<UploadFilesButtonProps>>())
How can I make it so I can map two of the callbacks in the props to Actions, so I can get something more like this:
Copy code
val uploadFilesButton: RClass<RProps> =
    rConnect<AppState, UploadFile, WrapperAction, RProps, UploadFilesButtonStateProps, UploadFilesButtonDispatchProps, UploadFilesButtonProps>(
        { state, _ ->
        },
        { dispatch, _ ->
            uploadFile = { dispatch(UploadFile(it)) }
            toggleUploadInProgress = {dispatch(ToggleUploadInProgress(it))}
        }
    )(UploadFilesButton::class.js.unsafeCast<RClass<UploadFilesButtonProps>>())