Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想在我的 clojure 程序中使用很多反应式(数据流)类型的编程技术。在 clojure refs 上使用“add-watcher”将足以做到这一点。一个简单的例子是在底层数据发生变化时更新 GUI。
是的,这确实是个好主意。当流数据发生变化时,我在自己的代码中使用它来更新 UI 元素。唯一需要注意的是,观察者在agent' 线程或主线程atom中同步调用 ifref或var。所以为了避免阻塞线程,不要在观察者中做太多的处理。如果您需要这样做,请创建一个future.
agent
atom
ref
var
future