We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e9f7fa5 commit 2daeb31Copy full SHA for 2daeb31
lib/src/commonMain/kotlin/org/reduxkotlin/Thunk.kt
@@ -27,12 +27,13 @@ fun <State> createThunkMiddleware(extraArgument: Any? = null): ThunkMiddleware<S
27
{ next: Dispatcher ->
28
{ action: Any ->
29
if (action is Function<*>) {
30
- try {
31
- (action as Thunk<*>)(store.dispatch, store.getState, extraArgument)
32
- } catch (e: Exception) {
33
- throw IllegalArgumentException()
34
-// Logger.d("Dispatching functions must use type Thunk: " + e.message)
35
- }
+ @Suppress("UNCHECKED_CAST")
+ val thunk = try {
+ (action as Thunk<*>)
+ } catch (e: ClassCastException) {
+ throw IllegalArgumentException("Dispatching functions must use type Thunk:", e)
+ }
36
+ thunk(store.dispatch, store.getState, extraArgument)
37
} else {
38
next(action)
39
}
0 commit comments