This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-02
Channels
- # admin-announcements (3)
- # architecture (5)
- # beginners (10)
- # boot (223)
- # cider (13)
- # cljsjs (2)
- # cljsrn (50)
- # clojure (208)
- # clojure-austin (16)
- # clojure-belgium (1)
- # clojure-india (1)
- # clojure-poland (13)
- # clojure-russia (130)
- # clojure-spec (27)
- # clojure-uk (144)
- # clojurescript (135)
- # css (2)
- # cursive (10)
- # datavis (1)
- # datomic (29)
- # dirac (9)
- # funcool (2)
- # hoplon (41)
- # jobs (3)
- # leiningen (6)
- # om (37)
- # onyx (20)
- # pedestal (1)
- # planck (1)
- # proton (4)
- # re-frame (45)
- # reagent (17)
- # rethinkdb (16)
- # ring-swagger (19)
- # schema (5)
- # specter (93)
- # sql (16)
- # test-check (33)
- # untangled (7)
@johanatan: any specific questions? I've built apps with css, sass and garden and I don't think it really matters from the point of view of re-frame.
how re-frame-y it is to put a reaction in the view instead of creating a subscription?
I'm worried about the potential messiness of the approach vs the code clutter
@nilrecurring: where are you getting the reaction from?
subscriptions are deduplicated
if you’re getting data from app-db, you should use a subscription
example:
(defn my-component []
(let [a (subscribe [:a])
b (subscribe [:b])
c (reaction (my-fun @a @b))]
(..do stuff with c..)
if you’re not getting data from app-db, it should probably be in app-db, and then use a subscription 🙂
That should be a subscription probably
my issue is that I use that reaction only there, while my other subscriptions are used 2+ times
That’s ok
That will work, but it’s probably an anti pattern
Like if that’s the only place in the codebase that it happens then no big deal
Also, you might be at risk of glitching
If a and b are both changed, you may get places where a is updated first which reruns c, then b is updated and reruns c again
I’m not 100% if this is one of those places, Mike Thompson would be able to say for sure
Ohhh that's true
I didn't thought of this
btw, in my-component
, are you passing a
, b
, and c
to an inner function?
yep, there's a lambda with no parameters that returns hiccup, it's a form2 component
Just checked, a and b shouldn't change at the same time, so glitching is not an issue
is it nice to subscribe to something inside other subscriptions?
Subscriptions return reactions after all
Yep it’s great to subscribe inside other subs
Because subs are deduplicated
So if you use a sub in 5 different places, only one reaction is created and run, and the reference is passed to all 5 callers
hi all, does anyone know a good way of writing tests for a re-frame subscription that relies on synchronous event dispatch to alter behaviour before assertions are made?
i like writing the test that way - it lets me know my events and subs are all wired up correctly
the problem is that when an event results in another event being dispatched i don't know how to wait for the second one to be completed before i make my assertion, and dispatch-sync
doesn't help in this instance because the nested dispatch doesn't honour it
@oliy there's been nothing to date. We've started work on a solution in the following repo. Which is not ready for prime time AT ALL. But thoughts are evolving. https://github.com/Day8/re-frame-test
This is the core of it: https://github.com/Day8/re-frame-test/blob/master/src/day8/re_frame/test.cljc#L29-L51
Concurrently, in that repo we are also trying to figure out how to run such tests on BOTH CLJS and CLJ. Which is proving a challenge
@mikethompson interesting thank you, i will probably cannibalise part of that for the meantime and keep an eye on progress. for what it's worth my first thought was to redef dispatch
to dispatch-sync
and see how far that got me as with that sort of test there's no browser render to yield to. also, i've found that with cljs async i can get tests working in chrome (local dev) that simply don't work in phantomjs (CI) but that is using a combo of cljs.test/async
and go
blocks which is apparently a no-go on phantomjs
Another testing question - the schema being checked against app-db is supposed to represent the entire application state's schema or just the part being modified?
@shaun-mahood: oh, I was just wondering how to integrate into lein and figwheel for automatic compilation and watching. I ended up using stylus (standalone exe) and a Makefile.
(Works perfectly. Stylus compiles to CSS and then figwheel picks that up and hands to the browser).
@johanatan: Figwheel has a SASS watcher as well https://github.com/bhauman/lein-figwheel/wiki/SASS-watcher. If you're not all in on SASS, you should definitely try garden as well - not sure if it integrates with figwheel directly, but just running lein garden auto
worked perfectly with figwheel for me and it removes the dependency on ruby. I found SASS pretty limiting in terms of abstractions compared to garden, so even though I liked it much better than just css moving to garden made a big difference to the ease of working with stylesheets for me.
Oh yeah, I was mixing up compass (for SASS) with stylus. I've never used Stylus...
Hey guys, anyone using re-frame with heroku? This issue could use your help: https://github.com/Day8/re-frame-template/issues/32