Re: why is state not passed to subscribers? This ...
# redux
Re: why is state not passed to subscribers? This has come up several times by various people. The answer had always been "because js redux does it this way" & the state is available easily through store.state. I've recently been doing some optimizations and found there could be good reason to pass the state for redux-kotlin. Reason being 'sychronized'. Chances are your using synchronized store for thread safety. This carries overhead of obtaining locks, so each call to store.state is getting a lock. If each subscriber does this it adds up! For my current project I'm using a store enhancer that does some custom subscription management and a custom callback that contains the new state so we avoid this problem. Curious if anyone does similar, or noticed the get state overhead. I'm tempted to change the core lib. It's a small change, but existing code bases may need to updated and we loose the 1:1 API matching with JS redux (which is probabaly does matter much at all). Thoughts?
KVision wrapper for ReduxKotlin (and Redux.js as well) uses callback with new state value. Just for convenience (JS runtime is single-threaded anyway, so synchronization is not an issue).
I think this would be a great addition. I always hated that in redux.js. It made writing middleware really annoying