This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
@sonnyto: I’m planning to add :no-index schema attribute to next DataScript version, so you could store stuff that is not comparable
is there an idiomatic way to do something like this?
(-> app-state
(swap! save-set)
(swap! #(assoc % :replacements nil))
(swap! #(assoc % :seed nil)))
obviously that doesn't work, I was trying to replace a do
form with several consecutive swaps
also -- is there a better channel for questions like that? (or is it more suited for Stack Overflow?)
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
cool, thanks! I'll try that
@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.yeah. I thought there was a benefit to doing it all within swap
(that wouldn't really apply to my app, but that was my impression)
Yeah, lots of ways of making the code shorter ... just depends on what's clearer to the following readers.
thanks
my last pass was to give it (apply comp fns), where fns all took & returned the contents of the atom as their only arg
@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 % ..)))
@jeremyraines: I might also be late but in particular assoc
allows more than just 2 params so: (assoc % :replacements nil :seed nil)
thanks!
@jeremyraines: may be this could also make a sense: (swap! save-set merge {:replacements nil :seed nil})
yeah, that looks like a good improvement
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..
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.
does anyone have experience with getting server-side rendering working in production like: https://github.com/pleasetrythisathome/om-server-rendering ?