Fork me on GitHub
#re-frame
<
2017-07-28
>
gadfly36101:07:22

Look for reactify-component

taylor12:07:11

I’m writing a ClojureScript app w/Reagent/Re-frame and I’m wondering how to properly handle logout when the user’s token expires. I’m assuming I should do something like have an AJAX interceptor that checks for 401s and then dispatches a “logout” event?

mikethompson12:07:51

Assuming you are using something like re-frame-http-fx you would make the on-failure handler set some state in app-db

mikethompson12:07:01

to capture the logged out state

taylor12:07:10

I am! That makes sense, thanks!

johnj14:07:29

Are you guys/gals more fond of pedestal than ring cause of the use of interceptors in re-frame?

johnj14:07:22

I'll need to check that one

mccraigmccraig14:07:53

yada is also interceptor based, async, very http compliant and gives you swagger for free - it ticked all my boxes

jebberjeb16:07:16

@lockdown- I've been using Pedestal recently. As you said, I like sticking w/ interceptors, but also it was easy to do Server Sent Events.

nidu17:07:06

Hello. I need a piece of advice regarding event handler organization. For example i have some handler for UI event :form/init which calls :user/fetch. UI shows loading progress and so :form/init should know when :user/fetch is done (or when specific :user/fetch.done is called). How can i know this inside :form/init while making :user/fetch :user/fetch.done generic enough (don't put inside logic for this specific form)?

akiroz19:07:44

@nidu You can't dispatch an event inside of an event. You could have a loading state in the app-db that gets updated by :user/fetch and :user/fetch.done then have your view subscribe on that.

akiroz19:07:13

events aren't function calls, they can't be nested; only queued.

nidu19:07:27

@akiroz but i can dispatch another event in reg-event-fx via dispatch, isn't it the same? Yeah, that's the point. I'd like :user/fetch to be used e.g. in different forms and every form would like to know when user is fetched. Probably these generic functions shouldn't be events?

akiroz23:07:59

@nidu nope, calling dispatch inside of an event will queue up the event. it gets handled after the current one is completed.

akiroz23:07:15

you probably want to have your :user/* events to only update the db (including its loading states) and have views react accordingly in the reactive flow.

jfntn23:07:58

I’m looking for an example re-frame app that uses a linked data model, where entities reference each other. Say something like books/authors/bookshelves, or conferences/speakers/talks, anyone aware of something like that?