hyper/lib/utils/config.ts

18 lines
629 B
TypeScript
Raw Normal View History

2021-09-07 03:32:49 -08:00
import {ipcRenderer} from 'electron';
import {require as remoteRequire} from '@electron/remote';
// TODO: Should be updates to new async API https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31
const plugins = remoteRequire('./plugins') as typeof import('../../app/plugins');
2016-07-13 12:44:24 -08:00
export function getConfig() {
return plugins.getDecoratedConfig();
2016-07-13 12:44:24 -08:00
}
2019-10-12 02:16:45 -08:00
export function subscribe(fn: (event: Electron.IpcRendererEvent, ...args: any[]) => void) {
2016-07-13 12:44:24 -08:00
ipcRenderer.on('config change', fn);
ipcRenderer.on('plugins change', fn);
2016-07-13 12:44:24 -08:00
return () => {
ipcRenderer.removeListener('config change', fn);
};
}