You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Usage is very similar to JS Redux and those docs will be useful https://redux.js.org/. These docs are not an intro to Redux, and just documentation on Kotlin specific bits. For more info on Redux in general, check out https://redux.js.org/.
Redux in multi-threaded environments brings additional concerns that are not present in redux
11
+
for Javascript. Javascript is single threaded, so Redux.js did not have to address the issue.
12
+
Android, iOS, and native do have threading, and as such attention must be paid to which threads interact with the store.
13
+
14
+
As of ReduxKotlin 0.3.0 there is `same thread enforcement` for the [getState](../api/store#getstate-_or_-state-property), [dispatch](../api/store#dispatchaction-any-any), [replaceReducer](../api/store#replacereducernextreducer-reducer-state-unit),
15
+
and [subscribe](../api/store#subscribelistener-storesubscriber) functions on the store. This means these methods must be called from the same thread where
16
+
the store was created. An `IllegalStateException` will be thrown if one of these are called from a
17
+
different thread.
18
+
19
+
If this `same thread enforcement` was not in place invalid states and race conditions could happen.
20
+
For example if `getState` was called at the same time as a dispatch, the state would represent a past
21
+
state. Or 2 actions dispatched concurrently could cause an invalid state.
22
+
23
+
Note that this is __SAME__ thread enforcement - not __MAIN__ thread enforcement. ReduxKotlin does not
24
+
force you to use the main thread, although you can if you'd like. Most mobile applications do redux on the main
25
+
thread, however it could be moved to a background thread. Using a background thread could be desirable
26
+
if the reducers & middleware processing produce UI effects such as dropped frames.
27
+
28
+
29
+
Currently `same thread enforcement` is implemented for JVM, iOS, & macOS. The other platforms
0 commit comments