运行在渲染器线程中全局传递的函数

时间:2019-06-17 12:03:39

标签: electron

我正在global中传递对象,并且当我执行传递的对象的功能时,即使我在main线程中运行代码,它也会在renderer线程中执行。

我认为这是设计使然,但是可以在renderer线程中执行它吗?

主线程(伪)设置

let shouldBeSetInRenderer;

const myObject = {
  setup: function setup() {
    shouldBeSetInRenderer = 'Important Value';
  }
}

global.shared = myObject;

渲染器线程(伪)设置

import {remote} from 'electron';

// This should be executed in the renderer thread to setup some variables
remote.getGlobal('shared').setup();

0 个答案:

没有答案