Fork me on GitHub
#re-frame
<
2016-08-02
>
shaun-mahood03:08:49

@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.

nilrecurring08:08:51

how re-frame-y it is to put a reaction in the view instead of creating a subscription?

nilrecurring08:08:31

I'm worried about the potential messiness of the approach vs the code clutter

danielcompton08:08:26

@nilrecurring: where are you getting the reaction from?

danielcompton08:08:40

subscriptions are deduplicated

danielcompton08:08:07

if you’re getting data from app-db, you should use a subscription

nilrecurring08:08:22

example:

(defn my-component []
  (let [a (subscribe [:a])
        b (subscribe [:b])
        c (reaction (my-fun @a @b))]
    (..do stuff with c..)

danielcompton08:08:24

if you’re not getting data from app-db, it should probably be in app-db, and then use a subscription 🙂

danielcompton08:08:06

That should be a subscription probably

nilrecurring08:08:17

my issue is that I use that reaction only there, while my other subscriptions are used 2+ times

danielcompton08:08:57

That will work, but it’s probably an anti pattern

danielcompton08:08:52

Like if that’s the only place in the codebase that it happens then no big deal

danielcompton08:08:05

Also, you might be at risk of glitching

danielcompton08:08:34

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

danielcompton08:08:56

I’m not 100% if this is one of those places, Mike Thompson would be able to say for sure

nilrecurring08:08:06

Ohhh that's true

nilrecurring08:08:14

I didn't thought of this

danielcompton08:08:28

btw, in my-component, are you passing a, b, and c to an inner function?

nilrecurring08:08:11

yep, there's a lambda with no parameters that returns hiccup, it's a form2 component

nilrecurring08:08:23

Just checked, a and b shouldn't change at the same time, so glitching is not an issue

nilrecurring08:08:06

is it nice to subscribe to something inside other subscriptions?

nilrecurring08:08:42

Subscriptions return reactions after all

danielcompton08:08:34

Yep it’s great to subscribe inside other subs

danielcompton08:08:40

Because subs are deduplicated

danielcompton08:08:08

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

oliy12:08:15

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?

oliy12:08:57

i like writing the test that way - it lets me know my events and subs are all wired up correctly

oliy12:08:02

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

oliy12:08:09

any ideas would be gratefully recieved

mikethompson12:08:04

@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

mikethompson12:08:34

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

oliy13:08:58

@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

oliy13:08:38

clj would definitely be a win in terms of ease of writing tests

mattsfrey15:08:06

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?

johanatan18:08:51

@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.

johanatan18:08:27

(Works perfectly. Stylus compiles to CSS and then figwheel picks that up and hands to the browser).

shaun-mahood19:08:42

@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.

johanatan19:08:21

I'm using Stylus

johanatan19:08:14

Thx for the info though.

shaun-mahood19:08:36

Oh yeah, I was mixing up compass (for SASS) with stylus. I've never used Stylus...

gadfly36120:08:40

Hey guys, anyone using re-frame with heroku? This issue could use your help: https://github.com/Day8/re-frame-template/issues/32