我已经进入 clojure/pedestal 项目大约 2 个月了,现在我正在学习 continue 并尝试使用一个来启用或禁用按钮上的点击事件。这个想法是我的报告有一个上一个和下一个按钮,我想根据一些数据启用或禁用这些按钮。我在我的应用程序模型中的继续看起来像这样......
:continue #{[#{[:report-scope]} continue-report-scope]}
然后我的继续功能看起来像这样。(原谅草率的代码和总是被证明是真的条件 - 我的 clojure 很弱,我一直在破解这个函数试图让它工作。
(defn continue-report-scope
[data]
(let [message (get-in data [:message])
report-scope (get-in data [:new-model :report-scope])
{:keys [start-date end-date]} report-scope
updated (get-in data [:updated])
added (get-in data [:added])
msgs []]
(when-not (or (nil? start-date) (nil? end-date))
(when (and (= (msg/type message) :report-scope-change)
(or (contains? updated [:report-scope :start-date])
(contains? updated [:report-scope :end-date])
(contains? added [:report-scope])))
(do
(conj msgs {msg/type :transform-enable msg/topic [:report-scope] :pager-prev [{msg/type :report-scope-prev msg/topic [:report-scope]}]})
(if (= 1 1)
(conj msgs {msg/type :transform-enable msg/topic [:report-scope] :pager-next [{msg/type :report-scope-next msg/topic [:report-scope]}]})
(conj msgs {msg/type :transform-disable msg/topic [:report-scope] :pager-prev []})))))))
问题是,这些消息永远不会到达渲染器。我尝试将消息/类型更改为不同的内容,然后将该类型/主题放入我的转换中,并且这些消息确实通过了。我的猜测是我需要以某种方式将此消息直接放在发射队列上(如果有这样的事情),但我不知道该怎么做。我试过查看 msg 元数据,并看到人们使用 ^:input 将消息直接放在输入队列上,但我找不到关于所有这些如何工作的好的文档。
有任何想法吗?