pedestal-app icon indicating copy to clipboard operation
pedestal-app copied to clipboard

pre-processor fails for messages with topic of msg/*

Open avescodes opened this issue 11 years ago • 0 comments

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

  1. 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)))})
    
  2. Consider modifying dataflow/find-message-transformer to handle non-seqable topics.

  3. Accept both of these issues as limitations and document them as such.

avescodes avatar Feb 14 '14 19:02 avescodes