Deep Dive - IPC w/ Electron & Context Bridge - Which IPC method is correct for you?

Поделиться
HTML-код
  • Опубликовано: 20 окт 2021
  • This video covers the pros and cons of using each of the common IPC methods inside electron. I will show you how to dispatch events and handle them, using context Bridge and a preload script as well as demonstrate why using ipcRenderer.invoke() is better than ipcRenderer.sendSync() for 99.98% of cases xD.
    More info on the electron docs:
    www.electronjs.org/docs/lates... 🔔 JOIN THE COMMUNITY 🔔
    ruclips.net/user/JSimplified... -- Subscribe xD
    ----------------------------------------
    -- Social Links --
    Discord - / discord
    GitHub - github.com/tylerlaceby

Комментарии • 41

  • @johnvargo8050
    @johnvargo8050 9 месяцев назад +3

    Struggled getting my invoke/handle block working for HOURS until I found this video. Thank you!

  • @DamonMedekMusic
    @DamonMedekMusic 2 года назад +6

    I'm using Electron and I've basically sectioned by preload script into 4 pieces. Renderer to Main, Renderer to Main to Renderer, Main to Renderer, and Main to Renderer to Main. This video did a great job explaining the first two sections. It took my awhile to digest all of this but it made a lot of sense eventually, thank you so much.

    • @tylerlaceby
      @tylerlaceby  2 года назад

      Of course. Glad you liked it.

  • @Barrosy
    @Barrosy Год назад +2

    This is such an explanatory video. Thank you so much!

  • @RadTwin
    @RadTwin Год назад +2

    Best explanation on RUclips right here

  • @wolf7115
    @wolf7115 2 месяца назад +1

    Thank you so much! I was having a ton of issues getting electron to work the way I wanted, and your explanation of invoke/handle solved everything for me.

  • @Einfach_Ben
    @Einfach_Ben 2 года назад +4

    Thank you so much, I ran through so many slightly older videos/docs and comments which used electron remote all through render process which apparently doesn't work anymore, but I did not realize that this was the solution I needed. The pain is over...

    • @datasagedev
      @datasagedev Год назад +1

      I second everything you just said Ben, its crazy how little content and support there is for Electron with both Docs and other sources.

  • @gbingol
    @gbingol 8 месяцев назад +1

    To the point and very nice tutorial! Thanks.

  • @RockieYang
    @RockieYang 9 месяцев назад +2

    Thanks for great explanation.

  • @mohammadagha8857
    @mohammadagha8857 2 года назад +2

    Thanks a lot for this great video.

  • @arsen3223
    @arsen3223 Год назад +2

    this is really helpful thank you

  • @vamparicW
    @vamparicW 2 года назад +2

    great video, thank you!

  • @ubidefeo
    @ubidefeo Год назад +2

    This was sooooo helpful!
    Thanks, Tyler.
    By the way, the GH link in the description points to a wrong url :)

    • @tylerlaceby
      @tylerlaceby  Год назад +1

      Glad you found it useful. Also thanks I’ll get that fixed asap

  • @Graducation
    @Graducation Год назад +2

    hey man everything is good buti am not able to set my app icon(it shows default electron) after running make command

    • @tylerlaceby
      @tylerlaceby  Год назад

      Sorry to hear that man. I sadly don’t know for sure but feel free to reach out on discord

  • @ukaszX-qt8eu
    @ukaszX-qt8eu Год назад +2

    Thanks. I have a propably simple problem to solve. I need IPC to connect python/electron. I have a python script that requires first no1 parametr, and secondly no2 parametr from user to start working. How to do it, can you give some examples, that we have simple python script which require some 2 variables from user to start, and it will be all activated from UI.

    • @tylerlaceby
      @tylerlaceby  Год назад +1

      What you want to do is communicate via child processes to python. You can send and receive messages using child processes and pipes.

  • @unloyal6396
    @unloyal6396 2 года назад +2

    Hi, thanks for the video!
    I am using vue.js and every time i try to run the window.api.greet function from my vue class in the script i get the error: TypeError: Cannot read property 'greet' of undefined
    Any idea how i can fix this?
    Thanks in advance.

    • @tylerlaceby
      @tylerlaceby  2 года назад +1

      I would first make sure the exportInMainWorld(“api”, {}); function is being called in your preload script.
      Then console log the window object. If that’s not working then feel feee to message me in the discord server and make sure that you are loading the preload script inside the browser window declaration

    • @unloyal6396
      @unloyal6396 2 года назад

      @@tylerlaceby Thanks!
      I forgot to actually call the function in the browser window, also i had to add :
      module.exports = {
      configureWebpack: {
      target: 'web'
      }
      }
      to the vue.config.js file

  • @p.p526
    @p.p526 9 месяцев назад +2

    Bro, Is it possible to receive data inside main process ipcMain.handle function? I'm seding the userId from renderer and tying to use on inside the handler function but it's not working, any other alternative for this?

    • @tylerlaceby
      @tylerlaceby  9 месяцев назад

      You should be able to use handle and invoke events or the on and send events.

    • @tylerlaceby
      @tylerlaceby  9 месяцев назад +1

      If you are still having issues feel free to reach out on my discord or watch this video to see the differences. Best of luck.
      ruclips.net/video/Tewl2YdBd6w/видео.htmlsi=j_Ms5IixZ22J9Yp0

    • @p.p526
      @p.p526 9 месяцев назад +1

      @@tylerlaceby Thanks bro for the support. Really appreciated.

  • @Verzach3
    @Verzach3 2 года назад +2

    Hey bro, nice video, can you share the source to use it as an example?.

    • @tylerlaceby
      @tylerlaceby  2 года назад

      Sadly I didn’t keep any of the source files. But if you need any help or need please feel Fred to ask here or in my discord server.
      Cheers

  • @kristianpurgar5068
    @kristianpurgar5068 2 года назад +2

    The repository is not active anymore, I get 404?

    • @tylerlaceby
      @tylerlaceby  2 года назад

      Yea I changed my username on GitHub from tylerbadger23 to tylerlaceby I have not updated the descriptions on older videos.
      Sorry 😁

  • @jasminescorp
    @jasminescorp Год назад +2

    This is so good, but unfortunately the github repo does not work

    • @tylerlaceby
      @tylerlaceby  Год назад

      Oh no. I still need to fix the repo link with my older videos. Sorry about that.
      The username is tlaveby for my GitHub xD

    • @jasminescorp
      @jasminescorp Год назад

      @@tylerlaceby thanks I tried both. Tylerlabeby and 23. You have so many good examples, would be awesome to take at the code.

  • @daviclor6670
    @daviclor6670 2 года назад +4

    This is a good tutorial, but it would be much more helpful if there were a working link to the source code.

    • @tylerlaceby
      @tylerlaceby  2 года назад +1

      Yea sorry I have not started posting direct source code yet. I should probably do that.

  • @narottambasnet1565
    @narottambasnet1565 2 года назад +1

    I have a child and a parent electron but somehow I am not able to communicate with the child from main process

    • @tylerlaceby
      @tylerlaceby  2 года назад +1

      When you say child electron do you mean a child process ? If so then I would be happy to help if you go in discord. But I would first suggest checking to make sure the communication is setup.
      Lastly remember that the main and child processes communicate over the electron iPad events.

  • @coryulrich6489
    @coryulrich6489 Год назад +1

    I'm trying to learn how to use node modules in electron because that was what made it sound so awesome for desktop applications, and I almost can't believe people thing doing this is not only good, but the best option in the industry at the moment. It's honestly so complicated I think I'd rather just start learning rust. Learning the intricacies of electron may as well be another language in and of itself.

    • @tylerlaceby
      @tylerlaceby  Год назад +1

      I mean if you want that’s fine but then you have to learn Rust and a while library. You do you man 👨

    • @coryulrich6489
      @coryulrich6489 Год назад

      @@tylerlaceby it's just a lot more difficult than anyone who talks about electron lets on. I finally gave up using a node module because the documentation and forum posts for doing so safely is a tangled nightmare. I was planning to play in rust anyways, and if the rest of the electron experience is like this I'll see if flutter is a better option for me.