Fork me on GitHub
#re-frame
<
2020-05-25
>
Mor Gazith08:05:03

hey, is someone here using intellij/cursive for re-frame and knows if it’s possible to make command+click go to definition of an event? i.e. have cursive understand something like [::a.e/log-event …] and jump to where :log-event was defined

p-himik08:05:45

Yes, Cursive has been aware of re-frame for some time now. But you have to use reg-event-* functions that are provided by re-frame - you cannot use any wrappers around them.

Mor Gazith08:05:54

so for example i have this at analytics.events:

(re/reg-event-fx
  ::log-event
  fn [] ...)
and at some other file:
(ns ...
    (:require [analytics.events :as a.e]))
(re/reg-event-fx
   :some-other-event
   (fn [...]
       {:dispatch [::a.e/log-event :something]}))

Mor Gazith08:05:21

when i cmd+click on ::a.e/log-event it does nothing

p-himik08:05:10

That's strange - something very similar works for me. Can you ask it in #cursive ?

p-himik08:05:24

re is re-frame.core, right?

Mor Gazith08:05:34

ooohhh…. good catch, no it’s a wrapper :face_palm:

Mor Gazith08:05:10

yeah, you’re right, changing it to

(re-frame.core/reg-event-fx ...)
seems to work

p-himik08:05:46

Yeah, I suffer in the same way. :) Colin has promised that there's something planned in this regard, IIRC.

Mor Gazith08:05:19

thanks for the help

👍 1
andre08:05:42

does it work only for reg-event-fx ? what about reg-fx or reg-sub ?

p-himik08:05:31

Didn't check reg-fx. Works for all event and sub functions for me.

Mor Gazith08:05:12

works for reg-fx as well (when i use re-frame.core directly, without a wrapper)

andre08:05:20

yeah for some reason even reg-event-fx doesn't work for me

andre08:05:54

will try to figure out why later

andre08:05:57

oh right it works only for namespaced keywords 🙂

Johnson10:05:19

Howdy all, I'm trying to fetch some data from an api and I keep getting a CORS error. Hoping someone here can help me 🙂 This is the error: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at . (Reason: CORS header 'Access-Control-Allow-Origin' missing)

p-himik10:05:22

It's not re-frame-related at all. The error is pretty self-explanatory, you just need to know some "what"s and "why"s about CORS: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS

Johnson10:05:28

Ah I see, the API isn't sending the response with an 'Access-Control-Allow-Origin' header Do you know of an easy way to bypass this just for dev that doesn't require me going back and modifying the API?

p-himik10:05:03

There's a client, there's a server, and there's a connection between them. 3 components, so 3 ways to fix the issue: 1. Change the client, i.e. the web browser you're using. Obviously should be avoided 2. Change the server. A preferred solution assuming that the same code will be used in production 3. Change the connection. I.e. plug into it a proxy that sets that header for you. A bit of a hassle to set up but may be fine for development

Johnson10:05:34

Okay, fair enough. I'll go and modify the api, thanks for you help

👍 1
mh.meraji15:05:36

Hi. I run my clojure-script code with shadow-cljs when ever there is a bug in the code (especially functions for view) the page completely goes out (I get a white blank page) and some error pops up on the console Is there any method to avoid losing the whole page despite of the exceptions thrown on different parts of the code? In other words what are the best practices for this kind exception handling for these situation? Thanks.

solf16:05:22

error boundaries

mh.meraji16:05:23

Thanks alot.