如何从continue发出转换启用消息

时间:2014-02-10 15:03:12

标签: clojure pedestal

我大约2个月进入一个clojure / pedestal项目,我刚刚学习继续并尝试使用一个来启用或禁用按钮上的点击事件。我的想法是我的报告有一个上一个和下一个按钮,我想根据一些数据启用或禁用这些按钮。我继续在我的应用程序模型中看起来像这样......

:continue #{[#{[:report-scope]} continue-report-scope]}

然后我的继续功能看起来像这样。 (原谅邋code的代码和总是证明是正确的条件 - 我的咒语很弱,而且我一直在试图让它起作用。

(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 / type更改为不同的东西,然后将该类型/主题放入我的转换中,这些消息确实完成了。我的猜测是我需要以某种方式将此消息直接放在发射队列上(如果有这样的事情),但我无法弄清楚如何做到这一点。我已经尝试查看msg元数据,并且看到人们使用^:input直接在输入队列上放置消息,但我找不到有关如何工作的良好文档。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

来自continue函数的消息旨在放置输入队列,它们用于在数据模型的转换流中启用递归。

然后,您应该在数据模型中查看指定的路径以进行更改并生成输出消息 对于基于这些更改的渲染器(大多数情况下,内置默认发射器功能就足够了)。

看看这张照片,我希望它能让事情变得更清晰:

App flow with continue