Fork me on GitHub
#re-frame
<
2017-02-09
>
pesterhazy11:02:49

@nrako I haven't had much luck customizing typeahead

pesterhazy11:02:17

I think it may need some work

nrako16:02:03

@pesterhazy thanks for the note. Will check it out...

negaduck17:02:55

hello. I’m trying to write an interceptor. This doesn’t work: (defn check-spec-interceptor [s] (re-frame/after (s/assert :db/good-state s))). I get an error: re-frame: when registering :initialize-db, got a function instead of an interceptor. Did you provide old style middleware by mistake? There is a re-frame/->interceptor, but I don’t understand how to use it.

negaduck17:02:44

never mind, made this work: (def check-spec-interceptor (re-frame/after #(s/assert :theproject.db/good-state %)))

curlyfry17:02:12

@negaduck I believe after takes a function.

curlyfry17:02:39

Beat me to it :)

negaduck17:02:53

@curlyfry, yes, the last line does that

curlyfry17:02:31

Was replying to your first message (too late)!

negaduck18:02:09

How to make sure only given keys are in spec? I have (s/def ::good-state (s/keys :req-un [::name ::active-panel])) and it doesn’t complain when the state also has :whatever true.

paul.nguyen18:02:03

@negaduck https://groups.google.com/forum/#!topic/clojure/fti0eJdPQJ8 Specifically, Alex Miller’s response using s/merge for s/keys and s/map-of

(s/def ::my-map2 (s/merge (s/keys :req [::a ::b])  (s/map-of #{::a ::b} any?)))
(s/explain ::my-map2 {::a 1 ::b 2 ::BAD 3})
In: [:user/b] val: 2 fails spec: :user/b at: [:user/b] predicate: string?
In: [:user/BAD 0] val: :user/BAD fails spec: :user/my-map2 at: [0] predicate: #{:user/a :user/b}

negaduck19:02:32

paul.nguyen, thank you