首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在openfin中,不同的小部件/窗口如何通信

在openfin中,不同的小部件/窗口如何通信
EN

Stack Overflow用户
提问于 2020-01-17 03:37:09
回答 1查看 124关注 0票数 0

与openfin一样,我们可以单独打开单独的小部件/窗口,它们如何相互通信,搜索了很多次也找不到任何相关信息,请帮助。

EN

回答 1

Stack Overflow用户

发布于 2020-04-19 18:08:46

您可以使用customContext将上下文从主窗口共享到其所有父视图

窗口(框架)中的

代码语言:javascript
复制
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 });
        });
    }
})

视图中的(内容)

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59776654

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档