Fork me on GitHub
#re-frame
<
2017-07-27
>
fabrao02:07:26

Hello all, is there any way to set more than one value for reg-event-fx to {:db (assoc db :dialog true) ... other assoc ...}?

sambev02:07:59

@fabrao you could use the thread first function:

{:db (-> db (assoc :dialog true)
              (assoc :other false)}

sambev03:07:11

you could probably use merge as well

sambev03:07:26

{:db (merge db {:dialog true :other false})}

mikethompson04:07:08

@fabrao if using merge be aware it only works to one level

mikethompson04:07:10

(merge {:a {:aa 2}} {:a {:bb 1}}) gives {:a {:bb 1}} and not {:a {:aa 2, :bb 1}}

mikethompson04:07:49

There's been many a paper cut from that

thomas09:07:27

Hi, I just made my first re-frame app and I would like to receive some feedback of possible, you can find it here: https://github.com/thomas-shares/todo-app2

curlyfry10:07:11

@fabrao assoc is variadic, just give it multiple pairs of keys and values and they will all be added. No need for multiple calls or merge. https://clojuredocs.org/clojure.core/assoc

sambev14:07:15

@curlyfry @mikethompson Thanks for the corrections! I didn’t know either of those things.

pedrorgirardi14:07:19

Hi, I would like all my event-db|fx to run a spec check afterwards, and I wanted that to be the default, so I wouldn’t need to pass the interceptor to every event handler. Is there a “proper way” of doing that? A wrapper fn would do, but I would prefer not to if possible, I don’t want to create an API on top of re-frame. Maybe what I’m trying to do is not appropriate, so feedback is very welcome 🙂

jebberjeb15:07:26

@pedrorgirardi In the past, I've used a wrapper function when I wanted to apply some base interceptor stack across the board.

pedrorgirardi15:07:35

thanks @jebberjeb! I’m considering the wrapper fn option, if there is not a “better way”, I might do that then.

jebberjeb15:07:10

@pedrorgirardi cool, I'm also curious to hear if anyone has any input on a more idiomatic solution.

pedrorgirardi15:07:52

yeah, me too.. and maybe there is 🙂

pedrorgirardi15:07:24

..and I’m using expound instead of the default s/explain in cljs.spec.alpha. expound has pretty good error messages

talgiat18:07:57

Does anyone have used https://github.com/nodename/stately or https://github.com/jiangts/re-state in large re-frame apps, any lessons learned or recommendations? thinking of adding it to our app (around 20K LOC), and wanted to get some feedback before doing so.

jiangts18:07:35

my fork basically just makes it usable with re-frame 0.9.x, which seemed to be less of a priority in the original stately repo.

jiangts18:07:53

it’s generally useful for complex, stateful components. I used a statechart to untangle a video player I was building. Really nice to have all the logic implicitly encapsulated in the declared states, transitions, and actions

jiangts18:07:48

however, for many simple, independent events and subscriptions it’s overkill. Only when events/subs need to be orchestrated in some manner is a statechart really useful in my experience

jhund18:07:15

@jiangts I am very interested in using statecharts for an app I’m building. Is there an example app using re-state?

jiangts18:07:35

@U0EP0D9FE I haven’t created an example app yet — I just grafted it into the codebase I’m working on. Not 100% sure if the original stately demos still work with re-state. Would be happy to put together a mini example after work sometime this week

jhund18:07:53

I’ve looked at stately in the past. I can look at its documentation to get a start.

jhund18:07:08

I will also look at what you changed relative to stately

jhund18:07:18

to figure out how to use re-state

talgiat19:07:39

@jiangts our app is 20K LOC and getting a bit out of hand. We basically break handlers and subs into separate controllers which loosely controls different pages (or panels) of the app, but they have dependancies between them, so I thought to have them represented as components in re-state

jiangts19:07:28

^^that might prove fruitful. Unfortunately, I’ve only used it for work, so I don’t have an example on github. But as mentioned, would be happy to put one on github sometime this week

jiangts18:07:11

hey — I’m jiangts and I’ve used it haha

talgiat19:07:50

hey @jiangts is the project you used it for on github or something internal?

yedi20:07:58

can you use re-frame/reagent components from vanilla react in JS

yedi20:07:44

components that are written in the conventional way (i.e: not leveraging reagent's reactify-component or current-component

lwhorton20:07:38

@yedi http://reagent-project.github.io/news/news060-alpha.html look at heading “Better interop with native React”

yedi20:07:11

@lwhorton thanks but i'm talking about using a reagent component from vanilla react, not using a vanilla react component from reframe

lwhorton21:07:55

hmm .. i’ve definitely done that before let me check something