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
fix(#285): add composeWithStateSync to resolve issues with enhancer order (#296)
* fix(#285): add composeWithStateSync to resolve issues with enhancer order
* fix: resolve PR comments
* chore: add type tests
* docs: update README getting started and add changes to FAQ
Co-authored-by: Maciej Małkowski <monkey3310@gmail.com>
Copy file name to clipboardExpand all lines: README.md
+25-5Lines changed: 25 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,20 +35,40 @@ electron-redux docs are located at **electron-redux.js.org**. You can find there
35
35
36
36
## Quick start
37
37
38
-
electron-redux comes as a [Redux StoreEnhancer](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer). To initialize your stores, you just need to decorate them in the `main` and `renderer` processes of electron with their respective enhancers:
38
+
### Basic setup
39
+
40
+
If you have a setup without any enhancers, also including middleware, you can use the basic setup. For the basic setup, electron redux exposes a [Redux StoreEnhancer](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer). You simply add the enhancer to your createStore function to set it up.
const store =createStore(reducer, stateSyncEnhancer())
54
+
```
55
+
56
+
### Multi-enhancer setup
57
+
58
+
> This setup is required when you have other enhancers/middleware. This is especially the case for enhancers or middleware which dispatch actions, such as **redux-saga** and **redux-observable**
59
+
60
+
For this setup we will use the `composeWithStateSync` function. This function is created to wrap around your enhancers, just like the [compose](https://redux.js.org/api/compose) function from redux. When using this, you will not need `stateSyncEnhancer` as this does the same thing under the hood. If you do, it will throw an error.
Copy file name to clipboardExpand all lines: docs/docs/faq/faq-general.md
+13Lines changed: 13 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,3 +6,16 @@ hide_title: true
6
6
---
7
7
8
8
# TODO
9
+
10
+
## Errors
11
+
12
+
### Received error "electron-redux has already been attached to a store"
13
+
14
+
There are 2 scenario's for you to receive this error message.
15
+
16
+
1. If you are using the `composeWithStateSync` function to install electron-redux, you do not need to manually add the `stateSyncEnhancer` as it does the same thing. It will throw an error if you try.
17
+
2. If you are using `stateSyncEnhancer`, `rendererStateSyncEnhancer` or `mainStateSyncEnhancer` in your createStore function, you may only add one of these in EACH process.
18
+
19
+
### Received error "Unsupported process: process.type = ..."
20
+
21
+
If you use `composeWithStateSync` or `stateSyncEnhancer`, we will determine in which process you are, the main or renderer process. We do this by checking the [process.type](https://www.electronjs.org/docs/api/process#processtype-readonly) variable which has been set by Electron. If you receive this error, you are either using this package in a non-supported environment, or this variable is not set properly
electron-redux comes as a [Redux store enhancer](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer). To initialize your stores, you just need to decorate them in the `main` and `renderer` processes of electron with their respective enhancers:
26
+
### Basic setup
27
+
28
+
If you have a setup without any enhancers, also including middleware, you can use the basic setup. For the basic setup, electron redux exposes a [Redux StoreEnhancer](https://redux.js.org/understanding/thinking-in-redux/glossary#store-enhancer). You simply add the enhancer to your createStore function to set it up.
const store =createStore(reducer, stateSyncEnhancer())
42
+
```
43
+
44
+
### Multi-enhancer setup
45
+
46
+
> This setup is required when you have other enhancers/middleware. This is especially the case for enhancers or middleware which dispatch actions, such as **redux-saga** and **redux-observable**
47
+
48
+
For this setup we will use the `composeWithStateSync` function. This function is created to wrap around your enhancers, just like the [compose](https://redux.js.org/api/compose) function from redux. When using this, you will not need `stateSyncEnhancer` as this does the same thing under the hood. If you do, it will throw an error.
0 commit comments