Gonzih / cljs-electron

ClojureScript + Electron + Figwheel + Reagent = ❤❤❤

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

*advice* electron api unclear interop

lazylazylazy opened this issue · comments

Really enjoying this project as a way of introducing myself to cljs and electron.

However it's a bit unclear how the electron.core calls the electron api in the renderer process. For example how would we be able to utilise the web-frame options or create menu objects?

Defining .-web-frame in the same way as .-BrowserWindow causes a compile error in the foreman task.

Can you please provide a javascript snippet of what you are trying to achive?

javascript From Electron docs -
const {webFrame} = require('electron')
webFrame.setZoomLevelLimits(1, 1)

However (def web-frame (.-web-frame electron)) creates a null pointer in main.js

Thanks

clarity - it is referred to as web-frame in many examples rather than webFrame, which creates the same problem anyway

What about (def web-frame (.-webFrame electron))?

yes, thank you, that sorted that. But now "web-frame is not a constructor" and set isn't made.

Please show your clojurescript code.

(.on @main-window "ready-to-show" #(set! (.-setZoomLevelLimits web-frame) (1, 1)))

also tried as a map but that kicked up a fuss on loading electron, not at compile.

many thanks!

setZoomLevelLimits is a function, not a property. set! mutates property, so you are doing couple of things wrong. You are mutating property that is function and then you are calling 1 as a function giving it1 as an argument.

Your code should look something like this:

(.on @main-window "ready-to-show" #(.setZoomLevelLimits web-frame 1 1))

Thanks for your help with this.
Total misunderstanding on my part - this needs to be called in the ui.core, not in the electron process.
Sorry for polluting your issues.

Glad to hear that you figured this out! Closing the issue.