Fork me on GitHub
#re-frame
<
2018-04-02
>
robert-stuttaford05:04:50

you should totally link to these lines from your new FAQ entry 🙂

mikethompson10:04:36

There's also dispatch-later effects, etc

achikin13:04:23

Hi, who have already tried kee-frame https://github.com/ingesolvoll/kee-frame . Any reviews?

eoliphant01:04:56

I’m experimenting with it, very clean, etc. Trying to figure out an issue when their not being a route when the page loads

dmi3y13:04:59

Hi everyone! Does anyone have an example or can give a hint on how to subscribe to a route change?

dmi3y15:04:12

Thanks! I'm sorry I didn't explain properly what I need. Here's a better explanation of the issue I'm having https://github.com/metosin/re-fill/issues/4

alex-dixon14:04:26

The error response I get with http-fx doesn’t seem to give a status code in the way I’d expect:

{: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}
Is there a way to get a :status 500 or somesuch?

mikerod14:04:47

@alex-dixon I think the :status comes directly from the response map returned from the xhr response

mikerod14:04:25

So to me, that looks like your response map itself (from whatever server you are getting it from) is returning a :status 0

alex-dixon15:04:54

Ok. Server was down…was expecting a 404?

alex-dixon15:04:57

The error handler is firing when I receive this, which seems triggered by an empty response body from the server. If I put {ok: true} it registers as success:

[:response nil]
[:last-method "POST"]
[:original-text ""]
[:last-error ""]
[:failure :parse]
[:status-text 
"Unexpected end of JS … been JSON keywordize"
Unexpected end of JSON input  Format should have been JSON keywordize
]
[:status 200]
[:uri ""]
[:debug-message "No Error"]
[:last-error-code 0]

alex-dixon15:04:04

I’m using (json-response-format {:keywords? true}) for :response-format

mikerod15:04:50

@alex-dixon I’m wondering at this point if your issue is not in re-frame’s :http-xhrio fx, but instead in the ajax lib response formatting

mikerod15:04:09

I don’t know how a :response nil is translating to a :status 0 for you

mikerod15:04:30

Not sure what you posted above.

mikerod15:04:38

Looks like a :status 200 in that

alex-dixon15:04:32

Yeah. I have a Node/Express server doing res.status(200).send() which seems to result in a parse error

alex-dixon15:04:16

If I provide some dummy body on the server like res.status(200).send({ok: true}) there’s no parse error and it registers as successful with re-frame

mikerod15:04:09

The request itself is processed via ajax.core/ajax-request. re-frame :http-xhrio doesn’t determine if it is an error or success it looks like

mikerod15:04:20

it just gives a success and error handler to that underlying lib

mikerod15:04:48

I don’t know enough at that level to have much good advice as to why your response is coming back like htat

mikerod15:04:57

Perhaps try debugging a bit at that level

alex-dixon15:04:06

Thanks. It’s workable but seems like it could be a bug. At least would like it to be smoother for beginners. I started writing a comparison of re-frame and Redux for JS devs over the weekend and :http-xhrio is a great feature that I mention quite a bit

👍 4
robert-stuttaford15:04:47

could be that http was 200 but the library threw its own error trying to understand the response: “Unexpected end of JS … been JSON keywordize”

👍 4
alex-dixon16:04:23

Is it possible to write handlers that do something like this?:

(reg-event-fx
  [::success ::routes/dashboard]
  (fn [{:keys [db]} x]
    (println "GQL success" x)))

alex-dixon16:04:52

I can do something like this but not sure if it’s better:

(reg-event-fx
  ::success 
  (fn [{:keys [db]} [_ route-key result]]
    (let [handler (route-key query->success-handler)]
      (when handler (handler result)))
    (println "GQL success" x)))

alex-dixon16:04:11

Pretty sure it’s not 😅

mikerod17:04:18

@alex-dixon I end up doing things like :dashboard/success

mikerod17:04:37

if you want to use the “real ns”, then like ::dashboard-success

mikerod17:04:55

it seems to me that you aren’t buying anything by putting a lookup map in the query->success-handler

mikerod17:04:35

might as well just lay out each “handler” as an event for its purpose. I don’t see dynamism in what you have above that would have any advantage to having a parameterized route-key in the event vector input

mikerod17:04:02

Unless you are wanting to have a fallback/default for unhandled things

mikerod17:04:32

I haven’t seen many examples of using non-keyword keys for registered events/subs in re-frame. I don’t know if anyone has pointed out to pro’s/con’s to doing that though.

alex-dixon17:04:49

Thanks. Hadn’t considered. There’s tradeoffs to each I suppose. Guess I was wondering if there’s something like rf/path or some middleware I could/should be using more. Most of the examples I’m seeing are as you describe

MegaMatt20:04:15

is re-com a dead project?

mikethompson22:04:23

@matthewdaniel we're making solid use re-com so it certainly isn't dead to us

mikethompson22:04:56

UIs libraries are difficult to generalise (in styling terms)

danielcompton22:04:10

@robert-stuttaford @soulflyer can you give ways to reproduce the errors you're seeing? I took a look at Bridge, but couldn't figure out how to get the errors you were seeing, Figwheel just 404'd on the JS

danielcompton23:04:06

I also took a look at hinh-anh and also couldn't get the errors to show up

MegaMatt23:04:14

@mikethompson it looks like pull requests are being ignored, i am more wondering dead as in not being maintained rather than unused

hoopes23:04:27

Hi, I'm looking for examples of routing where more "general" routes are hit before more specific routes. For example, if there were two routes for /admin/users and /admin/posts, the routing lib would detect that I'm attempting to enter the /admin route regardless of the sub-route, and check that my authenticated account has access. This may already be supported (currently trying to get familiar with bidi), but I haven't seen an example of it yet. Any help/pointers/links would be grealy appreciated.

eoliphant01:04:56

I’m experimenting with it, very clean, etc. Trying to figure out an issue when their not being a route when the page loads