Fork me on GitHub
#re-frame
<
2016-05-06
>
fasiha06:05:55

Using the lein re-frame-template with Secretary (`+routes`) for the first time. Trying to figure out what this whole client-side routing thing is all about. First question: I'd like to avoid having the "#" in my URL, so I commented out the ; (secretary/set-config! :prefix "#"). But what should I change the link to "#/about" to to use my non-# URL? If I click on a URL to just /about/, I get a error, not found. And my attempts to trigger a navigation event through (secretary/dispatch! "about") don't do anything. Am I on the right track or have I gone helplessly astray somewhere already?

fasiha06:05:56

I guess I can live with that # in my URLs, like "/#/" …

deas09:05:37

TIL: Bad things happen when you don't return the db from a handler. simple_smile

mikethompson11:05:23

@deas: use middleware which checks the schema of the db https://github.com/Day8/re-frame/blob/master/examples/todomvc/src/todomvc/handlers.cljs#L52 You pretty quickly find out when an event handler is wrong in some way.

deas11:05:38

@mikethompson: Good point. Thanks! simple_smile

fasiha13:05:49

@mikethompson: have you or anyone else ever run into a case where schema checks were a bottleneck or performance burden? I know they're really good for me, like, kale-grade good for me, but…

roberto14:05:05

schema checks are runtime checks, so you take a performance hit. I normally only enable them in tests.

mccraigmccraig14:05:49

@fasiha: schema checks kill my app performance, so i only use them in development

lwhorton17:05:58

does reframe handle lazy sequences without issue, or am I doing something wrong, or should I always realize a lazy when dealing with reactions?

lwhorton17:05:14

for example…

(let [thing (reaction (:thing @db)
       [filters (reaction (@db :filters)]
  (reaction (filter-with-filters @filters @thing)))
where filter-with-filters returns (filter …) (which is lazy).

lwhorton17:05:05

if I have a view subscribing to that reaction, is it going to trigger on change if the result is lazy?

lwhorton17:05:16

on second thought, perhaps this is a broader reagent question

fasiha19:05:18

@lwhorton: the way I understand it (as @hugobessaa was explaining to me the other day), if db changes, thing and filters will rerun their reactions. Then, filter-with-filters gets rerun. Any view that depends on this subscription will get rerun. So one way I'd look at the question is, it doesn't matter so much that the filters lazy list changed, but that db changed first.

fasiha19:05:46

From another perspective, supposing your ratom was a lazy seq, how would reagent know that it changed? It'd have to do (= old-lazy-seq current-lazy-seq) at some level, which performs a deep compare, which iterates over all elements of the lazy seq. (At least, that's what I derive from observing that comparing infinite lists appears to infinite loop: (= (repeat 1) (repeat 1)) ; doesn't end.)

fasiha19:05:06

So based on both those perspective, I'd tentatively say the answer to your question is, yes, the view will rerun if its subscribed lazy seq changes.

gadfly36120:05:58

@fasiha: regarding secretary and #, you can use https://github.com/venantius/accountant to mask the #. the reagent-template has a working version of secretary and accountant

gadfly36121:05:29

Just added a +cider option to re-frame-template. lein new re-frame myapp +cider CC: @escherize