This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-19
Channels
- # ai (3)
- # aws (1)
- # beginners (94)
- # boot (26)
- # cider (3)
- # cljs-dev (99)
- # cljsrn (86)
- # clojure (263)
- # clojure-dusseldorf (4)
- # clojure-greece (22)
- # clojure-italy (2)
- # clojure-quebec (1)
- # clojure-russia (12)
- # clojure-spec (71)
- # clojure-uk (123)
- # clojurescript (92)
- # core-async (4)
- # cursive (13)
- # data-science (2)
- # datomic (123)
- # docker (2)
- # emacs (15)
- # events (1)
- # graphql (2)
- # hoplon (71)
- # jobs-discuss (7)
- # lumo (5)
- # off-topic (12)
- # om (6)
- # onyx (97)
- # other-languages (4)
- # overtone (2)
- # pedestal (1)
- # re-frame (20)
- # reagent (33)
- # remote-jobs (1)
- # ring-swagger (1)
- # rum (5)
- # slack-help (6)
- # uncomplicate (1)
- # unrepl (33)
- # untangled (48)
- # vim (23)
- # yada (21)
Is there a way to prevent subscriptions from re-run’ing if they haven’t changed? Like component A is always deref’ing subscription B (which is expensive to run). If component A could just get the value from the last run that’d be great.
Subscription B isn’t using the app-db. Just another subscription.
Ah, never mind! I just needed to use reg-sub-raw
and not deref the app-db. Sorry for the noise! 🙂
code is here:
(re-frame/reg-event-db
:execute
(fn [db [_ input-val]]
#_(re-frame/dispatch [::http-get (str conf/execution-url "?token=" conf/token "&statement=" input-val)])
(re-frame/dispatch [::http-get ""])))
(re-frame/reg-event-fx
::http-get
(fn [db [_ url]]
{:http-xhrio {:method :post
:uri url
:timeout 5000
:format (ajax/json-request-format)
:response-format (ajax/json-response-format {:keywords? true})
:on-success [::good-post-result]
:on-failure [::bad-post-result]}}))
@cmal that is a problem with CORS (Cross-Origin Resource Sharing), you're making a request from one domain to another and you need to properly use CORS to allow that. This is a not problem specific to re-frame
@thegeez If the first 404 error is also a CORS problem, can you tell me how to bypass it? I am using figwheel
and maybe I should make the request host to be localhost:3449
. Thank you.
There is no bypass for CORS requests, the endpoint needs to properly implement CORS and allow CORS requests for this to work. This is not related to re-frame or figwheel or other tooling on your front-end.
If setting the headers in my localhost:6787 server to ALLOW ALL cannot solve the CORS problem, I thought maybe figwheel
could use something like ring-proxy
to proxy some url to local path. I tried to do that but the source code of figwheel
are too hard for me and the ring-proxy
cannot work as I expected.
Are there any other tooling on front end could let me request an API from other hostname?
Hey! todo-mvc example shows one way on how to validate app-db against schema. Is there any canonical way of validating (1) payloads of (dispatch …) calls (2) return values from sub handlers? I guess a “before” interceptor for event handlers could somewhat solve (1). Any better way? How about (2)?
@kamituel you could use schema or clojure.spec with :pre
and :post
conditions on your subs and event handler fns like shown here: https://clojure.org/guides/spec#_using_spec_for_validation
^ this is what I do
only in dev, not prod
I’m doing that for DB too, but it’d be great to have it for results of sub handlers too.
I guess :pre/:post could work. Is there a ClojureScript equivalent of https://github.com/jeaye/orchestra?