Fork me on GitHub

Look for reactify-component


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?


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


to capture the logged out state


I am! That makes sense, thanks!


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


I'll need to check that one


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


@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.


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)?


@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.


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


@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?


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


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.


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?