How to access Electron Api in my Angular Components?

This page summarizes the projects mentioned and recommended in the original post on /r/Angular2

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • nx-electron

    Electron schematics for nrwl nx platform

    I'm honestly not overly familiar with the "typical" setup of an Electron app (if there is such a thing — the docs make it sound pretty open-ended). I've only ever used it in the context of nx-electron (not that I can recommend it — it's not up-to-date with the latest versions of nx/Angular and it's kind of harrowing to get working even in the best case). But not being able to import anything in your entry-point seems like an unusual constraint — how are you bootstrapping the application?

  • electron-quick-start

    Clone to try a simple Electron app

    In any event, I just took a closer look at my project, and it looks like the key thing is to wait for Electron's ready event before registering the ipcMain listeners. So, taking Electron's quick-start example as a starting point, you would want to do it in the app.whenReady().then(() => { ... }) callback, probably just before creating the window. Does that help?

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

  • nx

    Smart Monorepos · Fast CI

    It's hard to know for sure without doing a deep-dive on your repo, but it sounds like you're not using a bundler for your Electron project. Honestly, if the Electron part of your app is pretty lightweight, I wouldn't even worry about it — if it ain't broke, don't fix it. :) If at some point this starts to feel excessively limiting, you could either look into setting up a custom build system for your Electron app (i.e., via Rollup or Parcel or Webpack, etc.) or look into migrating to Nx and using the nx-electron plugin I mentioned earlier (as long as you're on Angular <= v11). But either of those options open a huge can of worms — if you don't have a lot of experience with bundling/building JS applications, it is quite a deep rabbit hole to dive into.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts