This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-09
Channels
- # announcements (17)
- # babashka (8)
- # beginners (68)
- # calva (28)
- # clj-kondo (36)
- # cljsrn (1)
- # clojure (232)
- # clojure-dev (3)
- # clojure-europe (13)
- # clojure-nl (14)
- # clojure-spec (9)
- # clojure-uk (11)
- # clojuredesign-podcast (3)
- # clojurescript (38)
- # core-async (3)
- # cursive (1)
- # datahike (4)
- # datomic (4)
- # fulcro (56)
- # graphql (1)
- # helix (3)
- # honeysql (5)
- # introduce-yourself (1)
- # kaocha (2)
- # lsp (67)
- # malli (7)
- # meander (2)
- # off-topic (1)
- # pathom (9)
- # re-frame (55)
- # reitit (3)
- # releases (8)
- # remote-jobs (12)
- # shadow-cljs (12)
- # sql (3)
- # tools-deps (55)
- # vim (5)
- # xtdb (3)
Hello, I have been trying to use re-frame-http-fx
but I keep facing the issue detailed here - https://github.com/day8/re-frame-http-fx#status-0
Am able to access my GET http link with chrome and clj-http.client
. Does that mean it is likely to be a cross-site scripting issue?
The value of a sub is an arbitrary data. Before downloading it, you'd have to serialize it somehow.
Okay, so in that sense the way about it is to put it as text into a div and copy that? o:
The "traces" tab allows you to: 1. Switch the output to show only subs 2. Filter those subs 3. Press the "Print" button to output the value to the browser's JS console
In the JS console, you can do whatever you want to it. To make it more comfortable, you can right click the printed value and press "Store object as global variable".
Not sure what I was doing wrong but couldn't use the print button in the traces tab. But it did however display out all the details for me to copy (unlike when I was looking at app-db
tab where the last few values ended being left as ...
I remember someone in this channel talking about constructing effects data using function chaining; who was that? tell me your secrets again 😛
If I understand you correctly, it was probably @U3JH98J4R
@U4YGF4NGM refresh my memory a bit?
something about how you organize your events/effects, where instead of writing the effects in an event as data you use helper functions to construct the effects:
(rf/reg-event-fx
::something
(fn [{:keys [db]} [_ foo bar]]
(-> (do-thing {} foo)
(do-another-thing bar)
(do-one-last-thing))))
(rf/reg-fx
::alert
(fn [contents]
(js/alert contents)))
(defn alert [contents]
[[::alert contents]])
(defn alert-uppercase [contents]
(alert (string/upper-case contents)))
then if we have some process that we want to re-use in multiple handlers that will update state and perform some effects, we make a function
and we have another helper that lets us compose functions that have the signature db -> {:db, :fx}
(rf/reg-event-fx
::abc
(fn [{:keys [db]} [_ abc]]
(let [process (compose-effect-fns
do-thing
(fn [db] {:db (* db 2)}))]
(process db))))
and for new stuff we aren't allowing dispatches within a handler - keeping dispatches to only stuff the user did or reactions to outside processes
(defevent abc
[a b c]
:handler
(fn [{:keys [db]}]
{:db (* db a b c)
:fx (alert-fx/alert "AAA")}))
which produces a constant event:abc
equal to ::abc
, a function abc
, which when called will produce a vector you dispatch and a function handler:abc
which is your re-frame handler
do you mean app-db updates you do as soon as you launch the request or when it comes back
(defevent successfully-did-thing
[response]
:handler
(fn [{:keys [db]}]
{:db (* db 2)}))
(defevent failed-to-do-thing
[error]
:handler
(fn [{:keys [db]}]
{:db (/ db 5)}))
(defevent do-thing
[user-id]
:handler
(fn [{:keys [db]}]
{:db (+ db 1)
:fx (http-fx/request
{:uri "..."
:params {... user-id ... }
:on-success successfully-did-thing
:on-failure failed-to-do-thing})}))
(we re-wrote the normal :http-xhrio to support some stuff like functions for on-success, but same concept)
@U3JH98J4R That's at least the third time I see how you write extensively on this topic. Have you considered making a blog post or at least a detailed gist about it? Would be easier to share, publicly improve upon, and discuss in a persistent manner that's not possible on this Slack.
eh? its a pattern we still haven't worked out all the issues with and are using as a tool to patch up a large codebase. The ideal end point might be a library other than re-frame because it explicitly goes against what I think is intended design
plus its literally just the way elm does stuff being forced onto re-frame - not without reason, but certainly without elegance
a gist or something durable would be great for me! thanks for taking the time to write this down