Fork me on GitHub
#re-frame
<
2019-07-29
>
flowthing08:07:55

Came across some code that dispatches a re-frame event from a re-frame subscription handler. That feels kinda wrong to me, although I'm not sure I can put into words why. I guess I've always figured subscription handler functions oughta be pure, for one thing. Thoughts?

danielneal08:07:37

Yes, you are right, although the requirement does come up. Perhaps a clearer way of achieving the same thing would be to use https://github.com/vimsical/re-frame-utils/blob/master/src/vimsical/re_frame/fx/track.cljc

flowthing09:07:31

Thanks! That does look like it fits the bill. I'll look into it.

flowthing11:07:23

Sadly, https://github.com/vimsical/re-frame-utils/issues/5 prevents me from using that library in our project. Could fork it, maybe.

danielneal11:07:17

Or just copy paste :D I often do that with this kind of thing as you end up 'owning' it really

flowthing12:07:17

Yeah, that's one option. I can see myself using this in other projects down the line, though.

jahson09:07:30

The code in subscription mentioned above shoud be probably moved into reg-fx. The subscriptions are for extracting and computation of data before showing it to the user.

flowthing10:07:21

Right, but determining whether the event that is currently being dispatched from the subscription should be dispatched at all relies on multiple other subscriptions, and I don't think it's OK to use subscriptions in reg-fx, either.

metehan10:07:34

Hi, I made a simple app with re-frame. I don't need any security what is the fastest easiest way to persist app-db. Is there any library for sync'ing app-db with some real-db?

metehan10:07:13

It can be written to a file too I just want to keep app-db for next session.

metehan11:07:05

Thank you very much. I am checking it out.