Does anyone knows what the type arguments refers t...
# react
b
Does anyone knows what the type arguments refers to in these functions of Redux wrappers?:
Copy code
external fun <A, T1, R> compose(function1: (T1) -> R, function2: (A) -> T1): (A) -> R
&
Copy code
external fun <S, A, R> createStore(
    reducer: Reducer<S, A>,
    preloadedState: S,
    enhancer: Enhancer<S, Action, Action, A, R>
): Store<S, A, R>
R especially
r
From the sources and this description https://github.com/lawik123/kotlin-poc-frontend-react-redux my guess is R == WrapperAction
b
Just tested. You are correct
r
not that I know what it really is 😉
b
That makes two of us
But hey, as long as it compiles, right? 😄
j
Not sure if that is your last question, but if you're wondering what
WrapperAction
is, I believe I have found the answer. It's basically a built-in subinterface of the default redux
Action
that provides a default value for the
type
field, so that you can use plain data classes as actions. To be more precise, as far as I understood,
Store<S, A, R>
defines
A
as the input action type for
dispatch()
and the reducer, and
R
as the return type of
dispatch()
. When using enhancers, you can basically "enhance" the store to accept a new action type instead of
A
and return a new type from
dispatch()
instead of
R
. There is a built-in enhancer provided by the
kotlin-redux
wrapper, which makes
WrapperAction
the new return type of
dispatch
and
RAction
the new input type of
dispatch
and the reducer. Internally, it simply wraps the reducer and
dispatch
.