This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-31
Channels
- # aleph (38)
- # beginners (91)
- # boot (4)
- # cider (20)
- # clara (11)
- # cljs-dev (4)
- # clojure (179)
- # clojure-greece (1)
- # clojure-italy (16)
- # clojure-portugal (1)
- # clojure-russia (1)
- # clojure-sanfrancisco (1)
- # clojure-spec (183)
- # clojure-uk (50)
- # clojurescript (111)
- # core-async (24)
- # cursive (4)
- # datascript (11)
- # datomic (29)
- # fulcro (120)
- # gorilla (2)
- # jobs (1)
- # keechma (2)
- # keyboards (26)
- # leiningen (4)
- # luminus (7)
- # lumo (15)
- # off-topic (2)
- # onyx (31)
- # parinfer (12)
- # portkey (1)
- # protorepl (1)
- # re-frame (50)
- # reagent (106)
- # remote-jobs (1)
- # ring-swagger (2)
- # rum (10)
- # spacemacs (17)
- # sql (16)
- # test-check (1)
- # yada (2)
I've started using this shorthand for most of my subs. Does this make sense as something to add to re-frame, or is it just noise? (FWIW, I'm not crazy about the sub2
name I chose):
(defn sub2
"Shorthand for simple 'layer 2` usage of re-sub"
[key db-path]
(re-frame/reg-sub
key
(fn [db _] (get-in db db-path))))
(sub2 :page [:page])
(sub2 :user [:user])
(sub2 :uid [:user :uid])
...
One thing to be mindful of is that this makes it real easy to make a subscription that just returns data from the app-db. Which if used correctly is fine. Though I could see this leading to an incline to make a simple subscription and then do more data manipulation in a view.
I have a similar method reg-path-sub
in most of my projects for simple subscriptions
Hey, I don't know if anyone can help with this, but I"m going a bit crazy trying to figure out what's wrong. I'm using re-frame test to test my react native app, and getting the following error:
e),c.call(null,b,this.queue),d=cljs.core.next.call(null,e),e=null,f=0),g=0;else return null};re_frame.router.EventQueue.prototype.re_frame$router$IEventQueue$_exception$arity$2=function(a,b){this.queue=re_frame.interop.empty_queue;throw b;};
I think you may need to give just a tiny bit more context @danieleneal
It's a bit involved
so I've got a react native app, which I'm testing with reframe test
recently, I've needed to add assets to the app - pictures, fonts etc
this is done with (js/require "<asset-path>")
calls
however then my tests (which are running on node) complained, because require works differently in that context ->
<asset-path> is not a module
So I can get rid of these asset requires by monkey patching require, adding a bit of js before the app gets loaded
Yeah, my app is fine
even the tests run ok, but something breaks right at the end and dumps the message above
I think my understanding is a bit lacking - I guess there's a lot of asynchronous stuff going on with re-frame test - snapshotting state, restoring it etc
are you using re-frame-test?
to the extent i might be able to help you it would only be in pointing out that kind of assumption that it's easy to make and then miss later when you're tired and stressed 🙂
ah yeah, those "can't see the wood for the trees" errors...
I don't think it is expecting to be, but I think it should be able to work there
actually the CLJS line is simpler, it looks like the CLJ line is having to work hard to pretend to be a single-threaded environment 🙂
it has been so far - I've just separated my react-native bits from the handlers and subs, and testing the handlers and subs (which is where my mistakes always are)
no worries
a problem shared is a problem halved
this code is too complex for me to grok at a glance and i've not used it so I doubt i will be of much help to you
now I have half a problem 😄
gonna try a different tack I think...
I updated re-frame from 0.9.4 to 0.10.1 (also CLJS) and now I seem to be getting an error "Uncaught TypeError: goog.net.jsloader.load is not a function" from inside FigWheel but lein ancient
says I am all up to date. Anyone seen this?
sidenote really digging this two-layered subscriptions with an ‘extractor function’ and a ‘computation fn’.
do you just mean having one sub depend upon another with the first pulling from a key-path and the second computing on it? or it is something more?
Hello, all! Holy cow, I think re-frame is amazing — I’ve been using it for a week on my first cljs project, rewriting an app that I had written originally in TypeScript/React. I haven’t had this much fun programming in years! I’m amazed at how quickly things have come together (with the exception of hours spent trying to get closure compiler builds w/externs going.) I’m struggling with trying to understand why some re-frame/reg-event-fx :http-xhrio calls always call :on-failure. Looking at TypeScript version and server logs show that it’s returning 200 status code… Am I missing something obvious here? Many things in advance!
(re-frame/reg-event-fx
:send-scribename
(fn [{:keys [db]} _]
{
:dispatch [:send-hashtag-ajax-sent]
:http-xhrio {:method :post
:uri "/scribe"
:params {:text (:scribename-text db)}
:timeout 5000
:format (ajax/json-request-format)
:response-format (ajax/json-response-format {:keywords? true})
:on-success [:send-tweet-success]
:on-failure [:send-tweet-failure]}}))
Thanks in advance!(in short, the ajax call always calls the :send-tweet-failure
handler, seemingly regardless of the return code sent by the server. Am I doing something wrong in the code above? Thx!)
..and I’m even forcing the node.js server to always return res.status(200).send('success! changed scribe!');
Which means that it can only be return status code 200 — and yet :on-failure
is the what’s being called in my cljs client… 😕
Oh… Looking at re-frisk (which is a freaking technical miracle, IMHO), and saw this rather surprising result… Clearly, I’m doing something wrong in processing the return result…
Solved the issue… My server code was returning a string, not a JSON object. Fixed with this:
res.status(200).send({ text: "success! changed scribe!");
Neat!PS: holy cow. Being able to see all the events in re-frisk is gobsmackingly awesome. Incredible…
@sandbags yes that is what i meant. Im currently refactoring some old reframe code that started out on wrong foot. Now everything is so much cleaner
@sandbags Thanks!
That is what I do