Skip to content

Commit d2b6e15

Browse files
author
Jenn Kao
committed
Update README to include createSynchronizedStoreEnhancer enhancer usage
1 parent f0ef7a4 commit d2b6e15

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,28 @@ Using the convenience helper function `middleware`:
112112

113113
__Create a store__
114114
```
115-
val store = createThreadSafeStore(reducer, AppState(user, listOf()), applyMiddleware(loggingMiddleware))
115+
val store = createStore(reducer, AppState(user, listOf()), applyMiddleware(loggingMiddleware))
116116
```
117117

118118
You then will have access to dispatch and subscribe functions from the `store`.
119119

120+
__Create a synchronized store__
121+
```
122+
val store = createThreadSafeStore(reducer, AppState(user, listOf()), applyMiddleware(loggingMiddleware))
123+
```
124+
125+
Access to `store` methods like `dispatch` and `getState` will be synchronized. Note: if using a thread safe store with enhancers or middleware that require access to store methods, see usage below.
126+
127+
__Create a synchronized store using an enhancer__
128+
```
129+
val store = createStore(reducer, AppState(user, listOf(), compose(
130+
applyMiddleware(createThunkMiddleware(), loggingMiddleware),
131+
createSynchronizedStoreEnhancer() // needs to be placed after enhancers that requires synchronized store methods
132+
))
133+
```
134+
135+
Access to `store` methods like `dispatch` and `getState` will be synchronized, and enhancers (eg. `applyMiddleware`) that are placed above `createSynchronizedStoreEnhancer` in the enhancer composition chain will receive the synchronized store.
136+
120137
## Communication
121138
Want to give feedback, contribute, or ask questions?
122139

0 commit comments

Comments
 (0)