I wrote a middleware like this for async actions: ...
# redux
a
I wrote a middleware like this for async actions:
Copy code
override fun invoke(store: Store<AppState>): (next: Dispatcher) -> (action: Any) -> Any {
        return { next ->
            { action ->

                if (action is Request) coroutineScope.launch {
                    action.execute(store.getState, store.dispatch, api, db)
                }

                next(action)

            }
        }
    }
but the problem is that the state can get very out of wack in this situation if the coroutineScope is not on the same thread as the rest of the store. which in my case does not work out well.