Fork me on GitHub
#clojurescript
<
2015-08-08
>
Niki01:08:05

@sonnyto: I’m planning to add :no-index schema attribute to next DataScript version, so you could store stuff that is not comparable

jeremyraines01:08:06

is there an idiomatic way to do something like this?

(-> app-state
                     (swap! save-set)
                     (swap! #(assoc % :replacements nil))
                     (swap! #(assoc % :seed nil)))

jeremyraines01:08:54

obviously that doesn't work, I was trying to replace a do form with several consecutive swaps

jeremyraines01:08:53

also -- is there a better channel for questions like that? (or is it more suited for Stack Overflow?)

roberto01:08:38

the clojure channel maybe?

bhagany01:08:29

I think this channel is fine… not sure about idiom, but I think moving the threading macro inside a single swap would do what you want

bhagany01:08:55

like (swap! app-state #(-> … ))

jeremyraines01:08:44

cool, thanks! I'll try that

bhagany02:08:06

good luck simple_smile

mikethompson04:08:37

@jeremyraines: you seem to be doing successive changes to the value in app-state. Almost seems as if you want to get that value, make the series of changes, and then put it back in.

(let  [value  @app-state
       new-value  (-> value
                      save-set 
                     (assoc :replacements nil)
                     (assoc :see nil))]
   (reset! app-state new-value)
Which is certainly no shorter. But it does seem to convey the intention.

jeremyraines04:08:51

yeah. I thought there was a benefit to doing it all within swap

jeremyraines04:08:04

(that wouldn't really apply to my app, but that was my impression)

mikethompson04:08:56

Yeah, lots of ways of making the code shorter ... just depends on what's clearer to the following readers.

jeremyraines04:08:03

my last pass was to give it (apply comp fns), where fns all took & returned the contents of the atom as their only arg

bensu11:08:06

@jeremyraines: I might be a little bit late, but you probably want to call swap! once, and not by taking out the value and then returning it. That throws away all the benefits of an atomic transaction. Compose your functions with comp or -> and apply them all together (swap! app-state (comp save-set #(assoc % ...) #(assoc % ..)))

rauh13:08:50

@jeremyraines: I might also be late but in particular assoc allows more than just 2 params so: (assoc % :replacements nil :seed nil)

zarkone13:08:08

@jeremyraines: may be this could also make a sense: (swap! save-set merge {:replacements nil :seed nil})

jeremyraines13:08:56

yeah, that looks like a good improvement

zarkone13:08:49

seems like it has the same effect

zarkone13:08:43

and you can just send a hashmap as last param. With assoc you have to (apply assoc ...., and it wouldn't be so elegant with swap!, because it call function with first param..

paradoxquine20:08:57

anyone have a pointer? I’m trying to get set up with figwheel and rlwrap lein fighweel starts as expected but I don’t have the rlwrap benefits in my repl and there are no errors.

arohner21:08:51

does anyone have experience with getting server-side rendering working in production like: https://github.com/pleasetrythisathome/om-server-rendering ?

arohner21:08:21

I can get the absolutely trivial case working (i.e. sticking eval’d JS in html, w/o loading React), but then I start getting errors when I try to load react 0.12.2

arohner21:08:32

things like “document is not defined” and “navigator is not defined"