diff --git a/README.md b/README.md index ad1c187..b41ad8e 100644 --- a/README.md +++ b/README.md @@ -725,6 +725,8 @@ These constraints guarantee clear module boundaries: lazy modules are activated #### Example: valid lazy module +The Main Process + ```typescript @RgModule({ imports: [DatabaseCoreModule], // eager module @@ -732,15 +734,39 @@ These constraints guarantee clear module boundaries: lazy modules are activated ipc: [AnalyticsIpc], lazy: { enabled: true, - trigger: "analytics:init", + trigger: "init-analytics-lazy", }, }) export class AnalyticsModule {} await bootstrapModules([AppModule, AnalyticsModule]); +``` + +The Renderer process in React + +```typescript +import { useEffect, useCallback } from "react"; + +.... -// Renderer side: -await ipcRenderer.invoke("analytics:init"); +export const App = () => { + + const initAnalyticsModule = useCallback(async () => { + const { initialized, name, error } = await window.electron.invoke("init-analytics-lazy"); + + if (initialized && error === undefined) { + console.log('Success!', 'Module:', name); + } else { + console.log('Error!', 'Module:', name, error.message); + } + }, []); + + useEffect(() => { + initAnalyticsModule(); + }, [initAnalyticsModule]); + + return <>Home; +}; ``` #### Example: invalid (lazy + exports) diff --git a/devisfuture-electron-modular-1.2.16.tgz b/devisfuture-electron-modular-1.2.16.tgz deleted file mode 100644 index 6d88f28..0000000 Binary files a/devisfuture-electron-modular-1.2.16.tgz and /dev/null differ diff --git a/package.json b/package.json index f3d1317..f2ae892 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@devisfuture/electron-modular", - "version": "1.2.18", + "version": "1.2.19", "description": "Core module system, DI container, IPC handlers, and window utilities for Electron main process.", "type": "module", "main": "./dist/index.js",