他们是否有任何工具可以简化IPC并在单个网页和node.js进程之间进行数据编组?
我看过: http : //tangiblejs.com/posts/nw-js-and-electron-compared-2016-edition
其中概述了nw.js与电子之间的差异。 两者看起来几乎相同,但我喜欢在不需要时最小化复杂性,所以我倾向于nw.js以避免IPC的问题。
但这可能是一个错误,因为我看到这组中有超过10倍的关于电子的评论而不是NW.JS
(我的IDE将是Visual Studio Code,现在有一个NW.JS调试的扩展,但没有Electron的扩展)。
Are their any tools for simplifying IPC and doing data marshaling between a single web page and the node.js processes?
I have read: http://tangiblejs.com/posts/nw-js-and-electron-compared-2016-edition
Which overviews the differences between nw.js and electron. Both seem pretty much the same, but I like to minimize complexity when not needed, so I am leaning to nw.js to avoid the issues of IPC.
But this might be a mistake, since I see 10X more comments dealing with electron in this group as opposed to NW.JS
(My IDE will be Visual Studio Code, which now has an extension for NW.JS debug, but none for Electron).
最满意答案
我们之所以开始使用NWJS,也因为它支持chrome.serial 。 最近我将项目转换为电子,原因如下:
船上有更多大公司 更多提交,测试和维护 更多内置功能 例如, 阻止省电 更好的包装工具 更好的测试工具你是对的,NWJS没有主要/渲染过程的复杂性,但我发现很少有理由要处理IPC。
许多API仅在主进程中可用,但可以通过远程 API访问。 因此,例如,从我使用的渲染过程中访问主 process.argv :
{process} = require('electron').remote process.argv ...在我的index.js中,我不得不做一些IPC的事情,但电子有库来简化这个:
// ensure we only have a single instance, but pass args to renderer to open any files passed by explorer const shouldQuit = app.makeSingleInstance((argv, workingDir) => { win.webContents.send('open-instance', argv); })然后在我的渲染器代码中,我有以下内容:
ipcRenderer.on('open-instance', (event, arg) => { this.restoreAndFocus(); // TODO - handle another instance opening a file from explorer });We started using NWJS for that reason and also because it had support for chrome.serial. Lately I converted the project to electron for a few reasons:
More large companies on board more commits, testing and maintenance More built-in functionality eg, block power save Better packaging tooling Better test toolingYou're right that NWJS doesn't have the complication of the main/render processes but I've found very few reasons to have to deal with IPC.
Many of the APIs are only available in the main process but can be accessed via the remote API. So for example to get access to the main process.argv from the render process I use:
{process} = require('electron').remote process.argv ...In my index.js I've had to do a few IPC things but electron has libraries to simplify this:
// ensure we only have a single instance, but pass args to renderer to open any files passed by explorer const shouldQuit = app.makeSingleInstance((argv, workingDir) => { win.webContents.send('open-instance', argv); })Then in my renderer code somewhere I have the following:
ipcRenderer.on('open-instance', (event, arg) => { this.restoreAndFocus(); // TODO - handle another instance opening a file from explorer });更多推荐
发布评论