Giter Site home page Giter Site logo

IPC example about nextron HOT 14 CLOSED

yt-dlx avatar yt-dlx commented on August 31, 2024
IPC example

from nextron.

Comments (14)

Psycokwet avatar Psycokwet commented on August 31, 2024 2

Note that a fresh project from

npx create-nextron-app my-app --example basic-lang-javascript-python
cd my-app
npm install && npm run dev

This exact set of command launch the app on my mac

from nextron.

bm777 avatar bm777 commented on August 31, 2024 1

@yt-dlx Hi, in this template, you can see how we send data from the frontend, to the js backend via IPC.


In that example:

  • front the frontend, we send window.ipc.send('run-sh', value) via this ipc.send
  • and, in the backend, we receive the signal via ipcMain.on:
ipcMain.on('run-sh', async (event, value) => {
  console.log('DEBUG: starting process') // for dev mode
  event.sender.send('log', 'Running...') // for prod mode
  await startProcess(event, value)
})

I hope it helps :)

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

Capture

what am i doing wrong? I cloned the example folder and ran 'yarn dev'

from nextron.

bm777 avatar bm777 commented on August 31, 2024

@yt-dlx doo you have preload.js file inside the main folder?
that might be the cause, it is define and exposed in that file.

And when creating a windows, you should pass it like this:

mainWindow = createWindow('main', {
            width: 1000,
            height: 700,
            webPreferences: {
              preload: path.join(__dirname, 'preload.js'),
            }
          })

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

@bm777 in this version there was no preload.js 'https://github.com/saltyshiomix/nextron/tree/main/examples/basic-lang-javascript-python'

can i use the preload.js from the repo?

from nextron.

bm777 avatar bm777 commented on August 31, 2024

It should appear if you do:

npx create-nextron-app my-app --example basic-lang-javascript-python

If not, you can copy this preload.js and past it in your main/

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

I have tried with the preload.js but I am facing the same error.
Kindly please help me: https://github.com/yt-dlx/yt-dlx/tree/main/package

image

from nextron.

Psycokwet avatar Psycokwet commented on August 31, 2024

Instead of cloning to start your working directory, did you create a whole new project from npx create-nextron-app my-app --example basic-lang-javascript-python ? This will help greatly if you don't start from a clone.

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

@Psycokwet I tried with the yarn create but same error of window.ipc.
I have also tried the preload.js.

from nextron.

bm777 avatar bm777 commented on August 31, 2024

@yt-dlx Oh I got the issue:
There is a helper folder missing. @Psycokwet is right, you didn't create the project with that template. if you did it, it would have automatically also created that folder. it seems, you are trying to integrate it into your project.

The missing folder is this ->
https://github.com/saltyshiomix/nextron/tree/651967d7df3d0f7cb306f7d4296866f994fbeb5d/examples/_template/js/main

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

@bm777 @Psycokwet

I've implemented the changes using 'yarn create' as suggested, but the issue persists. Would you mind reviewing the details?

You can find the commit with the updates here: https://github.com/yt-dlx/yt-dlx/tree/main/package

from nextron.

Psycokwet avatar Psycokwet commented on August 31, 2024

If you really did start your project with npx create-nextron-app my-app --example basic-lang-javascript-python
You should have this file structure
Screenshot 2024-05-23 at 10 20 26

But in your github example, I see that :
Screenshot 2024-05-23 at 10 20 07

Those are differents, what did you do ?
You still miss at least scripts, but I would start anew instead of trying to fix an install made by hand

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

@Psycokwet @bm777

I followed these steps:

  • npx create-nextron-app package --example basic-lang-javascript-python
  • cd package
  • npm install && npm run dev

Yet the same issues. window.ipc

Tested Environments:

Commit:

Note:

  • I am able to run the code without IPC but not with IPC
  • CodeSandBox

image

from nextron.

yt-dlx avatar yt-dlx commented on August 31, 2024

Thnks guys. I have fixed the issue using electron-vite

from nextron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.