Fork me on GitHub
#re-frame
<
2018-02-11
>
mikethompson00:02:09

@itruslove thankyou for putting me straight.

derpocious00:02:12

Hey guys, I'm having a n00b issue

derpocious00:02:29

I am trying to register "handlers" for doing async stuff with re-frame/register-handler

derpocious00:02:57

then I dispatch the event as usual #(re-frame.core/dispatch [:load-items])

derpocious00:02:12

but I'm getting the error ":load-items is not a registered event"

derpocious00:02:25

Do I need to somehow let me app know that I have handlers?

derpocious00:02:39

Or dispatch the event differently?

derpocious00:02:43

or something else?

chrismdp00:02:08

do you have the event defined with reg-event-db or reg-event-fx?

derpocious00:02:41

I'm not defining an event for it. I'm just using frame/register-handler

chrismdp00:02:57

> re-frame.core/register-handler has been renamed re-frame.core/reg-event-db. There’s now three kinds of event-handlers, -db, -fx and -ctx. Event handlers of the 2nd and 3rd kinds should be registered via the new registration functions re-frame.core/reg-event-fx and re-frame.core/reg-event-ctx

derpocious00:02:09

requiring my handlers.cljs file in core.cljs worked! 🙂

chrismdp00:02:28

which version of re-frame are you running?

derpocious00:02:19

I created the project a few days ago with lein re-frame ...

derpocious00:02:09

why no icons?

derpocious00:02:55

I like re-frame a lot. It's funny thought bc to me it is way more similar to angular's ngrx than react+redux

mikethompson00:02:30

Good to hear. Always interesting to hear the perspective of those coming in fresh from other paths.

mrdaak14:02:26

Hello! New member here. This must be a trivial mistake but I would be really grateful if someone would point it out. I keep getting this error message while querying my GraphQL server:

[:uri ""]
[:last-method "POST"]
[:last-error " [0]"]
[:last-error-code 6]
[:debug-message "Http response at 400 or 500 level"]
[:status 0]
[:status-text "Request failed."]
[:failure :failed]
Here is the event handler:
(re-frame/reg-event-fx
  ::request-it
  (fn [{db :db} _]
    {:http-xhrio {:method :post
                  :uri  ""
                  :params {:query "{ court(id: 2) {id}}"}
                  :format (ajax/json-request-format)
                  :response-format (ajax/json-response-format {:keywords? true})
                  :on-success [::process-response]
                  :on-failure [::bad-response]}
     :db  (assoc db :loading? true)}))

The same query is working with curl. Thanks a lot!

gklijs16:02:28

Sorry, don't see any obvious things wrong. I'm a bit new to GraphQL myself, but use re-graph, but queries and subscriptions working well. https://github.com/oliyh/re-graph/

danielcompton17:02:26

@milos.mrdakovic1 take a look in your console and network connection in devtools, status 0 means something went wrong and the request wasn’t attempted

danielcompton17:02:32

if I had to guess I’d say it’s CORS

manutter5119:02:07

Weird, I have an event handler registered with re-frame/reg-event-fx, it’s been working fine until today, I can put console.log statements in to verify that the reg code is running, but now suddenly re-frame is insisting that the handler is not registered.

manutter5119:02:41

Are there any known gotchas that I ought to be looking for?

manutter5119:02:16

I’m definitely require-ing the ns

mrdaak19:02:00

@danielcompton It was CORS. Thanks a lot! @gklijs Thanks for the suggestion. I'll definitely have a look.

manutter5121:02:19

Ah, I see, I added an intermediate function to do the actual dispatch, and both it and the caller were adding the square brackets, so I was getting [[:my-weird-event]] instead of [:my-weird-event], and the error message was saying No handler for [:my-weird-event]. The square brackets should have given it away, but I’m used to seeing square brackets around events in re-frame, so I didn’t notice.