mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-26 14:45:50 +00:00
Update content/tutorials/build-apps/build-a-desktop-wallet-in-javascript.md
Co-authored-by: Jackson Mills <aim4math@gmail.com>
This commit is contained in:
@@ -308,7 +308,7 @@ Here we first call our helper function `getValidatedLedgerIndex()` and then broa
|
||||
|
||||
This example shows how to do Inter Process Communication (IPC) in Electron. Technically, JavaScript has no true parallel processes or threading because it follows a single-threaded event-driven paradigm. Nonetheless Electron provides us with two IPC modules called `ipcMain` and `ipcRenderer`. We can roughly equate `ipcMain` to a backend process and `ipcRenderer` to a frontend process when we think in terms of client-server applications. It works as follows:
|
||||
|
||||
1. We started by creating a function that enables the frontend to subscribe to backend events via the ContextBridge (in `view/preload.js`)
|
||||
1. We started by creating a function that enables the frontend to subscribe to backend events via the `ContextBridge` (`onUpdateLedgerIndex` in `view/preload.js`)
|
||||
2. Then we make the function available by putting it in a preloader script to ensure it is loaded and can be used by the frontend.
|
||||
3. On the frontend, we can then use that function to attach a callback that handles frontend updates when the event is dispatched. We could do this in the console, in a `<script>` tag in the frontend or in our case in a separate file.
|
||||
4. Lastly, we dispatch the event from the main logic in `index.js`via `appWindow.webContents.send('update-ledger-index', value)`.
|
||||
|
||||
Reference in New Issue
Block a user