This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-17
Channels
- # aws (16)
- # beginners (82)
- # boot (29)
- # cider (43)
- # cljs-dev (90)
- # cljsrn (14)
- # clojure (79)
- # clojure-dev (12)
- # clojure-greece (4)
- # clojure-italy (12)
- # clojure-russia (81)
- # clojure-shanghai (1)
- # clojure-spec (39)
- # clojure-uk (28)
- # clojurescript (159)
- # consulting (1)
- # cursive (16)
- # data-science (6)
- # datomic (18)
- # devops (3)
- # emacs (22)
- # figwheel (1)
- # graphql (15)
- # hoplon (3)
- # jobs (1)
- # jobs-discuss (8)
- # leiningen (1)
- # luminus (6)
- # lumo (1)
- # off-topic (18)
- # om (6)
- # onyx (38)
- # pedestal (30)
- # perun (3)
- # re-frame (38)
- # reagent (8)
- # ring-swagger (2)
- # rum (2)
- # sql (2)
- # unrepl (14)
- # untangled (1)
- # vim (8)
Hello all, how do I encode application/x-www-form-urlencoded for
(re-frame/reg-event-fx
::http-post
(fn [_world [_ val]]
{:http-xhrio {:method :post
:uri ""
:params data
: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]}}))
In params? I tried some like :params {:username username :password password} but it not encode
I'm guessing you should use :format (ajax/url-request-format)
I haven't done it myself but that's what I would try
are there any examples of writing clj tests when using the jvm interop functions? like testing a subscription function, or testing an event handler which has some interceptors.
or would you instead write your code like this:
(defn name-fn [db _ _]
(:name db))
(rf/reg-sub :name name-fn)
And just test name-fn
directly, skipping the re-frame part of things.sashton: This is how I do
thanks @U0V9BJR9V. How do you test handlers which have interceptors? Do your tests just pass data to you function in a form that matches what the interceptors would have done?
(defn some-id-fn [db v]
...)
(reg-event-db
:some-id
[add-some-token]
some-id-fn))
In this case, I could test some-id-fn
separately, but my test would have to format the input data in a way that matches what add-some-token
does.right exactly
In a way, that keeps the test focused on just what some-id-fn
is responsible for. But on the other hand, it means I could forget to add an interceptor, or an interceptor could change and it wouldn’t get caught in my test
it's unfortunate that we don't get full coverage with this method but the unit tests are pretty simple to set up since you're just testing functions
Hi guys, I made of fork of re-frame to try to port its goodness to new lands (aka rum) and without global state https://github.com/chpill/re-frankenstein
@chpill did you check scrum ? https://github.com/roman01la/scrum
hi! is there a way to register a global interceptor? i’d like to display a friendly error message when errors like this happen “re-frame: no :fx handler registered for:”
I have a standard-middlewares
that is a collection of interceptors I include for every event handler I register
I don't know if there's a way to register middleware globally
gotcha, thanks. I also looked at the source, and, sadly, I dont see a way to detect that a handler is not registered… it looks like it only goes to console 😞
The only trick is they’re grouped by kind
so if you don’t know that in advance you’ll have to try every kind/id combination
oh i see. that’s a bit different from what I was trying to do. I wanted a runtime error/event/notification if the code tries to dispatch an event that is not registered.
Yes, I did! In fact, I did not plan to fork re-frame at first. I was just discussing with the creator of scrum about some of the design decisions in both libraries. I ended up digging so deep into re-frame that I kind of saw a way to reuse most of re-frame without using the global state. And use rum on top 🙂
@chpill I took a quick look, and expected to see the frank
passed around the app as the state container, but it doesn’t seem like that's how it works?
@U051KLSJF There are several tricks. For the views, @U0EM88XL7 is right, they can access frank
via the react context (thanks to the with-frank
mixin.
basically, users still continue to use the classic registering mechanism like reg-event-db
, but when you do (frank/create)
it derefs the value of the handler registry, and replace the handlers and interceptors that affect global state with some that affect only the freshly created local-db
Oh I forgot to mention, indeed, the root mixin that injects frank
into the context also injects partially applied dispatch functions https://github.com/chpill/re-frankenstein/blob/2e36ed5a19370a890f795ecb96ae9e03807a65cb/src/re_frame/rum.cljs#L45-L46