Which is the best place to synchronize Electron and Ionic?

Hi,
I’m developing an App that calls an Ionic app into an Electron window.
It works, and I’m also passing some data from Electron to Ionic using IPC and the ElectronService module.

I’ve only this problem, the data arrives from Electron to Ionic too late.
The call that gets the data from Electron is in the module app.components.ts:

import { ElectronService } from 'ngx-electron';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {

  @ViewChild(Nav) nav: Nav;
  rootPage:any = LoadingPage;
  pages: Array<{title: string, component: any}>;


  constructor(public platform: Platform,
              public statusBar: StatusBar,
              public splashScreen: SplashScreen,
              public settings: SettingsProvider,
  ....
              private electronService: ElectronService
              ) {
    platform.ready().then(() => {
      statusBar.styleDefault();
      splashScreen.hide();

        this.electronService.ipcRenderer.on('sync-app-data', (event, sharedData) => {
          console.log("@@@ sync-app-data da Electron @@@");
          settings.initWSManagerWithElectronData(sharedData);
        });
...

Looking at the logs in the Chrome console I can see that the data arrives when the constructor of the Tabs section and the constructor of the first page have already been executed.

Is it possible to make sure that these constructors are executed after the data arrives?
Which is the best place to synchronize the two apps with this.electronService.ipcRenderer.on() ?

thank you

cld

1 Like