Fork me on GitHub

I am working on the reframe and created a component using reagent/create-class and inside :reagent-rendor, I have a condition, which filter the data and those data I am adding to the reframe db atom like below

(defn do-something
          (fn [{:keys [data payload status]}])
            (if (= data "something")
            (dispatch [:do-something-else 3]])
            (dispatch [:do-something "riyu"]]))
Is it right to call dispatch method anywhere? or we should call it always when even occurred If we cannot call dispatch function, How to insert the data in reframe db


Don't call dispatch in the render function. The right approach is outlined here:


thanks for response @U2FRKM4TW, How can I add the data into db if I want to ?


Have you read the page that I linked?


yes, But in my scenario, I am designing a pagination, where as I wanted to store each page db value, which I am doing for pagination


I'm sorry but I have no clue what you mean. I've implemented pagination many times, and it has never required dispatching events from within the render function itself (i.e. not as a reaction to some user input).

😂 1

I have re-frame app using http-xhrio to obtain CSV data from a server. It's all working but I would like to offer the data as a file to download. I was hoping to hand it off to the browser but don't know the mechanisms to achieve that. Can anyone point me in the right direction?


Not re-frame specific at all. Just create an <a download href="...">...</a> on your page with the right URL.


If you don't want a link but rather want the download to happen as a reaction to some user's action (which is not a click on a URL), you can use e.g.


Oh so just magic that up after I have the data back?


I need to send an auth token to the backend so it can't be a simple link ... AFAIK


Well, you can do it all manually, there's no magic. :) But making it work properly across browsers used to be a pain. Maybe it's not anymore, I haven't checked for a few years.


What do you mean by "send" in this case?


I mean include as an Authorization Bearer .... header


Yeah, you have to use a separate AJAX request then, unless that endpoint is the same server and your app and it supports cookies.


it is on the same domain ... a Lambda behind an API GW behind CloudFront. I could change everything to cookies but that feels like a pain now and we want some POSTs via that site too so I'm not so enthusiastic about doing it


I mean I'm in control of everything so I could do the cookies thing but cookies feel yucky if you know what I mean


when I say magic I just meant create it on the back of some event dynamically 🙂


Actually, no clue what you mean by cookies being yucky. As far as I'm aware, manually storing and providing authorization tokens is much worse in any situation where you could use secure cookies that are specifically designed to be used for authentication.


ok, the integration to authentication service I'm using (OKTA) uses access tokens so that's what I'm using


Looking at the README, he recommends the Content-Disposition header, which I am setting so maybe it's getting lost in the infra


hmmm, no ... it's coming through but is somehow being ignore by the browser


ok, I used saveAs on http-xhrio success. As I guess you know AJAX does not offer a way for the browser to save files directly

👍 1