@devisfuture/electron-modular 1.2.18 → 1.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +29 -3
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -725,6 +725,8 @@ These constraints guarantee clear module boundaries: lazy modules are activated
725
725
 
726
726
  #### Example: valid lazy module
727
727
 
728
+ The Main Process
729
+
728
730
  ```typescript
729
731
  @RgModule({
730
732
  imports: [DatabaseCoreModule], // eager module
@@ -732,15 +734,39 @@ These constraints guarantee clear module boundaries: lazy modules are activated
732
734
  ipc: [AnalyticsIpc],
733
735
  lazy: {
734
736
  enabled: true,
735
- trigger: "analytics:init",
737
+ trigger: "init-analytics-lazy",
736
738
  },
737
739
  })
738
740
  export class AnalyticsModule {}
739
741
 
740
742
  await bootstrapModules([AppModule, AnalyticsModule]);
743
+ ```
744
+
745
+ The Renderer process in React
746
+
747
+ ```typescript
748
+ import { useEffect, useCallback } from "react";
749
+
750
+ ....
741
751
 
742
- // Renderer side:
743
- await ipcRenderer.invoke("analytics:init");
752
+ export const App = () => {
753
+
754
+ const initAnalyticsModule = useCallback(async () => {
755
+ const { initialized, name, error } = await window.electron.invoke("init-analytics-lazy");
756
+
757
+ if (initialized && error === undefined) {
758
+ console.log('Success!', 'Module:', name);
759
+ } else {
760
+ console.log('Error!', 'Module:', name, error.message);
761
+ }
762
+ }, []);
763
+
764
+ useEffect(() => {
765
+ initAnalyticsModule();
766
+ }, [initAnalyticsModule]);
767
+
768
+ return <>Home</>;
769
+ };
744
770
  ```
745
771
 
746
772
  #### Example: invalid (lazy + exports)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devisfuture/electron-modular",
3
- "version": "1.2.18",
3
+ "version": "1.2.19",
4
4
  "description": "Core module system, DI container, IPC handlers, and window utilities for Electron main process.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",