desktop-application - 不同的小部件/窗口如何在 openfin 中进行通信
问题描述
与openfin一样,我们可以单独打开单独的小部件/窗口,它们如何相互通信,搜索了很多都找不到任何东西,请帮助。
解决方案
您可以使用从主窗口共享上下文到其所有父视图customContext
在窗口(框架)
const me = fin.Window.getCurrentSync();
me.on('options-changed', async (event) => {
if (event.diff.customContext) {
const myViews = await me.getCurrentViews();
const customContext = event.diff.customContext.newVal;
myViews.forEach(v => {
v.updateOptions({ customContext });
});
}
})
在视图中(内容)
const me = fin.View.getCurrentSync();
const broadcastContext = async (customContext) => {
const myWindow = await me.getCurrentWindow()
await myWindow.updateOptions({ customContext })
};
const addContextListener = async (listener) => {
await me.on('options-changed', (event) => {
if (event.diff.customContext) {
listener(event.diff.customContext.newVal);
}
});
}
参考资料 - https://cdn.openfin.co/docs/javascript/stable/tutorial-customContext.html
推荐阅读
- c - C中的特殊#define选项
- c# - C#:带有 .net 核心框架的可重用库中的控制器
- android - 滚动时如何检查互联网是否不存在或速度很慢?
- reactjs - 在 React 应用程序中隐式初始化 firebase
- node.js - Inside ngOnInit() subscribing a url through service and getting a ID which eventually has to be passed to diff method in same ngOnInit()
- javascript - not able to validate array of objects correctly using is-my-json-valid npm module
- python - 当两个按钮使用相同的功能时,我怎么知道哪个按钮正在使用
- javascript - Angular 7 Singleton Service:没有服务提供者
- vue.js - why electron builder dont include files
- python - Python3 - 设置保存路径