For todays post on electronjs I will be going over a quick example of the send method of the webContents object of a browser window object instance. The reason why I am writing a post on this is because even though I have only wrote a few example of electronjs thus far I can all ready see that this will be a feature that I will be using with a lot of future projects.
The general idea here is that the send method is a way to go about emitting an event for a render process, and so my attaching an event hander for a method that I define in my preload script, it can be used as a way to replay to a custom menu option in the browser window. Speaking of preload scripts, and custom menus, this example will also be a good starting point for these things, however this is still not a getting started with electron type post as I have wrote that one all ready.
The source code example that I am writing about here is on Github along with any additional assets that I might be using for this example. I also have all the source code examples for my various other posts on electronjs thus far located in the same repository.
I just wanted to make a quick example of the send method of the web contents object, for the sake of my own reference for the most part. When it comes to some actually project examples I have a few ideas on the drawing board at least, but I still think that I need to work out a few more basic examples like this just for the sake of learning the basics of electronjs thus far. That is not to say that this is nit a feature that I find myself using often, it most certainly is all ready, in just about any example in which I need to trigger custom client side events.
With my application that I am using to create videos called videoground I am using the send method of the web contents object for all the various events that I want and need for that prototype that might turn into my first real electronjs project. I have all ready wrote a post on the state of my video ground project example if you are interested. If you are looking for another simple hello world type example of the send method of web contents I have another post that has to go with the get all windows static method of the browser window object that might also be relevant to this as I am also using the send method to trigger front end events that way.