[英]sharing clojurescript atom between different js files (in different pages) on node js
I'm using node-webkit with clojurescript to make my desktop app, and I met a problem when I tried to share an atom between multiple windows(with different js file including.) 我正在使用带有clojurescript的node-webkit来制作我的桌面应用程序,当我尝试在多个窗口(包括不同的js文件)之间共享一个原子时遇到了一个问题。
When I define a node-global-variable as (set! js/global.foo (atom bar))
, it does create a global variable as an atom, but when I try to call reset!/swap! 当我将node-global-variable定义为
(set! js/global.foo (atom bar))
,它确实将全局变量创建为原子,但是当我尝试调用reset!/ swap!时, on the atom through another js file in another window, it crashes, telling me that swap!/reset! 通过另一个窗口中的另一个js文件在原子上崩溃,它崩溃,告诉我swap!/ reset! method not supported on type atom.
原子类型不支持该方法。
And I tried another way, I defined an atom using (def foo (atom bar))
, and (set! js/global.baz foo)
, then I moved all swap!/reset! 然后我尝试了另一种方法,我使用
(def foo (atom bar))
和(set! js/global.baz foo)
定义了一个原子,然后移动了所有swap!/ reset! functions to the js which I defined the foo, and other js files only reads js/global.baz without any attemption to write it...then I found that as bar is reset. 我定义了foo的js的函数,而其他js文件只读取js / global.baz,而没有任何尝试写它的动作...然后我发现bar被重置了。 the value of global.baz doesn't change.
global.baz的值不变。
I searched a lot on these without getting any information about it, it seems that few people are using node-global-variables in cljs. 我在这些工具上进行了大量搜索,但未获得任何相关信息,似乎很少有人在cljs中使用node-global-variables。
I need some help....thanks 我需要一些帮助。
To persist data between pages you may use one of persistence options . 要在页面之间保留数据,可以使用其中一种保留选项 。 I think Storage-Atom is well suited for your needs.
我认为Storage-Atom非常适合您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.