diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-12-23 13:40:47 +0100 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2021-12-23 15:48:30 +0100 |
commit | 950fb9be8061e2a26e0536b98c6a3ee230618f54 (patch) | |
tree | b136dcc9add0d268a2e7a6288ec934a86d03b652 /packages/preload/src/index.ts | |
parent | feat: Add shared package for electron ipc (diff) | |
download | sophie-950fb9be8061e2a26e0536b98c6a3ee230618f54.tar.gz sophie-950fb9be8061e2a26e0536b98c6a3ee230618f54.tar.zst sophie-950fb9be8061e2a26e0536b98c6a3ee230618f54.zip |
feat: Main to renderer store synchronization
Patches are send in one direction only, from the main to the renderer,
so all actions have to go through the context bridge and the renderer
IPC to modify the store in the renderer. This makes the store in the
main process a single source of truth, which simplifies debugging and
state persistence.
The store in the renderer is connected to redux devtools for inspection,
but playing back the state in the devtools won't change the sotre in
main process.
Diffstat (limited to 'packages/preload/src/index.ts')
-rw-r--r-- | packages/preload/src/index.ts | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/packages/preload/src/index.ts b/packages/preload/src/index.ts index 830901a..19d1285 100644 --- a/packages/preload/src/index.ts +++ b/packages/preload/src/index.ts | |||
@@ -1,10 +1,7 @@ | |||
1 | import { contextBridge, ipcRenderer } from 'electron'; | 1 | import { contextBridge } from 'electron'; |
2 | import { RendererIpcMessage, SophieRenderer } from '@sophie/shared'; | ||
3 | 2 | ||
4 | const sophieRenderer: SophieRenderer = { | 3 | import { createSophieRenderer } from './SophieRendererImpl'; |
5 | buttonClicked() { | 4 | |
6 | ipcRenderer.send(RendererIpcMessage.ButtonClicked); | 5 | const sophieRenderer = createSophieRenderer(); |
7 | } | ||
8 | }; | ||
9 | 6 | ||
10 | contextBridge.exposeInMainWorld('sophieRenderer', sophieRenderer); | 7 | contextBridge.exposeInMainWorld('sophieRenderer', sophieRenderer); |