Fork me on GitHub
#re-frame
<
2016-12-24
>
mattsfrey11:12:49

Hey, trying to upgrade to 0.8.0, have been converting everything over to reg-event-db from register-handler, everything is throwing a warning such as:

re-frame: when registering  :profile/send-emails-fail , got a function instead of an interceptor. Did you provide old style middleware by mistake? Got:  fndebug[handler]

mattsfrey11:12:00

where the register code looks like:

(re/register-handler
  :profile/send-emails-fail re/middleware
  (fn [db]
    (re/dispatch [:notifications/add-toast {:type     :error
                                            :text     (str "Error sharing profile, please try again.")
                                            :duration 5}])
    (update-in db [:account :profile] dissoc :send-emails)))

mattsfrey11:12:20

(register-handler here aliases to reg-event-db btw)

mattsfrey11:12:41

and the re/middleware is:

mattsfrey11:12:44

(def middleware [(when ^boolean js/goog.DEBUG debug)
                 dispatch-once-support
                 re-frame/trim-v])

mattsfrey11:12:08

any ideas what I'm doing wrong? this syntax seems like it should work given the readme

andre11:12:18

middleware should be an interceptor

andre11:12:38

(def trim-event
  (re-frame.core/->interceptor
    :id      :trim-event
    :before  (fn [context]
               (let [trim-fn (fn [event] (-> event rest vec))]
                 (update-in context [:coeffects :event] trim-fn)))))

andre11:12:09

@mattsfrey look at the last picture, to understand how interceptors works

mattsfrey11:12:28

yes I just got it working using that lol

limist13:12:43

For re-frame's event handlers and reg-event-fx in particular, what are valid return values for our handler functions please? The docs mention that an empty map {} is ok, per the section https://github.com/Day8/re-frame/blob/master/docs/Effects.md#db-not-always-needed but how about nil? (seems to work, just want to double-check) Any preference of convention, to express the intention of no further effects? Thanks.

shaun-mahood18:12:06

@limist: I think the convention is an empty map, not nil.