This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-02-21
Channels
- # arachne (1)
- # aws-lambda (50)
- # beginners (10)
- # boot (59)
- # capetown (4)
- # cider (9)
- # cljsjs (27)
- # clojure (249)
- # clojure-berlin (8)
- # clojure-finland (7)
- # clojure-germany (1)
- # clojure-italy (6)
- # clojure-nl (7)
- # clojure-russia (91)
- # clojure-spec (100)
- # clojure-uk (61)
- # clojureremote (2)
- # clojurescript (171)
- # core-async (11)
- # cursive (31)
- # data-science (1)
- # datascript (2)
- # datomic (11)
- # dirac (2)
- # emacs (16)
- # events (1)
- # hoplon (142)
- # juxt (4)
- # lein-figwheel (9)
- # leiningen (10)
- # luminus (7)
- # lumo (44)
- # mount (3)
- # off-topic (150)
- # om (18)
- # onyx (5)
- # perun (12)
- # planck (12)
- # protorepl (13)
- # re-frame (28)
- # reagent (8)
- # ring (1)
- # ring-swagger (10)
- # spacemacs (2)
- # specter (11)
- # sql (14)
- # untangled (99)
- # vim (18)
- # yada (2)
Here's a question I havn't seen or considered before: How do you setup a http request to download a file from re-frame? Is it possible? Is there an fx handler for it?
@escherize Hmm, l'm not sure what part of this would be specific to re-frame. I think the most common way to download a file is to just use a html link. Could you give a more specific example of what you want to do?
Yeah, we are using a link as it is. 🙂 Ideally I'd have (dispatch [:xxx]) -> download a file. but the way it is now we use a bit of html to provide a link to click that sends the request that does it.
escherize: What kind of request is that? It's not just an attribute on the html element?
(reg-event-fx
:download-file
(fn [{:keys [db]} [_ file-url]]
{:db db
:http-xhrio {:headers {:Authorization (str "token " EXAMPLE_TOKEN)}
:uri file-url
:method :get
:timeout 8000
:response-format (json-response-format {:keywords? true})
:on-success [:println "file downloaded"]
:on-failure [:identity]}}))
[:button {:on-click #(dispatch [:download-file ""])} “download”]
I’m not sure why it wouldn’t be more difficult than this simple snippet 🙂
@escherize dyu mean your re-frame app is serving the file, or you want your app to download the file to the local filesystem or memory ?
ha ha yeah I know it works — on my machine at least ^_^
hm. When I have (enable-re-frisk!)
, then nothing gets rendered at all in ios safari.
there are some strange 404 errors in ios safari console: https://www.dropbox.com/s/f7ch26bkxazrj86/Screen%20Shot%202017-02-21%20at%2016.00.35.png?dl=0 https://www.dropbox.com/s/xjfy4v8f1g6jyba/Screen%20Shot%202017-02-21%20at%2015.57.31.png?dl=0
Does anyone run cljs code in ios safari? I’m not sure, but it seems it just loads resources in a random order and I get errors because of this, different set of errors on every page reload.
@negaduck i run cljs code on ios safari and cordova+wkwebview
i haven't seen any errors like that though
@mccraigmccraig, I love cordova, used to play with cljs code in it. It worked flawlessly a while ago.
does it work ok if you do some cljs optimisations ? :simple
or :whitespace
?
i.e. concatenate all the js
mccraigmccraig, it works if I do $ lein cljsbuild min once
, it does :optimizations :advanced
no, dev builds are normally :optimizations :none
for speed and so that cljs reloading works - but :none
produces one output js for each input cljs
mccraigmccraig, btw I configured cordova to get resources from webserver on my laptop so 1. I didn’t have to rebuild the app and 2. figwheel worked — that was awesome
sounds interesting @negaduck - can you point to any docs on how to do that ?
i could have done with that yesterday - i do most of my debugging in chrome, but i had to debug some cordova local file handling
@mccraigmccraig, it’s mainly <content src="redirect.html" />
in config.xml + <allow-intent href="*" />
: https://github.com/koddo/ryctoic/blob/master/client-mobile/config-dev.xml
that looks interesting