pedestal-app
pedestal-app copied to clipboard
pre-processor fails for messages with topic of msg/*
I am writing a multi-screen app and am trying to log incoming messages using :pre, a use case suggested by Brenton. Since I wanted to see all messages, I used a path of :**
e.g.:
(defn log-input [msg]
(.log js/console "PRE" (pr-str msg))
[msg])
(def example-app
{...
:pre [[:* [:**] log-input]]
...}
The error I see in the JS console is "Uncaught Error: :io.pedestal.app.messages/app-modelis not ISeqable". The first messages a multi-screen app receives are in the format:
{msg/topic msg/app-model msg/type :add-named-paths :paths [] :name :example}
It seems that dataflow/find-message-transformer can't handle msg/app-model since it's not a seqable topic. This also means that :pre can't be used to hook into msg/app-model (which I am interested in) e.g.:
:pre [[:* msg/app-model log-input]]
;; I would have thought being wrapped in a vector would work but it doesn't
:pre [[:* [msg/app-model] log-input]]
Possible solutions
-
Consider a default :input-adapter that ensures all topics are vectors. This fixes
**
and being able to select just app/model topics::input-adapter (fn [m] {:key (msg/type m) :out (let [topic (msg/topic m)] (if (vector? topic) topic (vector topic)))})
-
Consider modifying dataflow/find-message-transformer to handle non-seqable topics.
-
Accept both of these issues as limitations and document them as such.