Fork me on GitHub
#re-frame
<
2020-07-16
>
wegi09:07:02

Is it good practice to use conditionals in effect-handlers? For Example: If a value is present in app-db, then emit one effects map and if not, do another?

p-himik09:07:20

You're mixing something up. Did you mean "event handlers" in the first sentence? If so, then it's a perfectly valid thing to do.

wegi09:07:32

Yeah, of course, sry

wegi09:07:47

Thanks for the answer

mikethompson01:07:29

@U49RJG1L0 You'll often see code like this

(fn [db v]
  (cond-> db 
    (some-condition? v) (assoc :something :to-add) 
    (another-predicate> db)) (update :key some-fn)))

mikethompson01:07:49

^^^ the real lesson here is that cond-> can be useful

wegi07:07:20

Haha, true never used it before. 😄 will have a look at it.

wegi13:07:43

Another question: When I have a component called my-component whats the difference between me calling it like a normal function (my-component) and including it with the vector notation [my-comontent] ? I'm guessing the function call has the downside of accidental execution, but I can't find any more info on this.

wegi13:07:20

Yes indeed, thank you :thumbsup: