This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-05-30
Channels
- # arachne (2)
- # beginners (8)
- # boot (19)
- # chestnut (2)
- # cider (1)
- # clara (1)
- # cljs-dev (31)
- # cljsrn (82)
- # clojure (163)
- # clojure-dusseldorf (7)
- # clojure-greece (1)
- # clojure-italy (4)
- # clojure-norway (3)
- # clojure-russia (24)
- # clojure-sg (5)
- # clojure-spec (6)
- # clojure-uk (42)
- # clojurescript (239)
- # core-async (4)
- # cursive (10)
- # data-science (18)
- # datascript (1)
- # datomic (110)
- # emacs (16)
- # euroclojure (1)
- # events (1)
- # figwheel (1)
- # hoplon (22)
- # keechma (2)
- # klipse (5)
- # lein-figwheel (3)
- # leiningen (7)
- # luminus (27)
- # melbourne (2)
- # mount (5)
- # nyc (7)
- # off-topic (35)
- # om (20)
- # onyx (49)
- # pedestal (41)
- # re-frame (31)
- # reagent (18)
- # remote-jobs (9)
- # ring (4)
- # ring-swagger (1)
- # spacemacs (6)
- # specter (6)
- # uncomplicate (3)
- # unrepl (9)
- # untangled (54)
- # yada (11)
Hello all, I dumb question, is there any way to get information from session after http-xhrio call?
I have this component which consists retrieves form data from the server and displays it and allows editing as well. So in my app-db
has the structure as follows:
{ :form-data {...}
:editable-form-data {...}}
The editable-form-data
stores the UI changes which haven’t been persisted yet. So at the initial load of the component I make the xhr call to server to get the form-data
which also needs to be copied over to editable-form-data
field.
Right now there a db-event which assocs the result of xhr call to both the fields in app-db. This works but it feels hacky to be honest. Are there any suggestions on doing this better?That seems pretty sensible. You could also make use of local state in your reagent components to keep the edited state but that's probably harder
Is there a kind of dual/equivalent of the effectful handlers for subscriptions that side effect or call out to javascript land. I'm looking at making a subscription for window dimensions in react native
danielneal: I don't believe there is anything like that. Is there a reason the dimensions cannot be put into the app-db and have the subscription use that?
@U051H1KL1 I dunno about native, but in the browser you'd do this:
(.addEventListner js/window
(fn [event]
(dispatch [:resize XXX])))
Then, in the event handler for`:resize`, you'd put the new size details into app-db
And then subscribe from app-db
as normal.
The XXX would have to be replaced with code that got the current size information and added it to the event being dispatched.ah cool, yep, I think it will work in native just like that
there's a similar global event listener I can add
thanks!
Hi, I found that in projects generated by re-frame-template
, there is a (defn ^:export init [] ... )
entry function. May I ask which library need this entry? re-frame
reagent
or cljsbuild
? Thanks!
Does anyone know of a place in the reagent / re-frame docs that warns against out-of-date subscription values being used in event handlers?
In other words, always use the app-db as a source of truth, not the values that are liable to change during the lifecycle of a reagent component.
Using re-frame.test/run-test-sync
I’m getting ERROR You can't call dispatch-sync within an event handler.
for handlers that return :dispatch
fxs. Is there a workaround that doesn’t involve running async?
If an interceptor places a map into the co/effect part of the context, does that persist to the next dispatch call, or is the db the only thing that persists?
Hello all, I´m doing this
(reg-event-fx
:processar-login
(fn
[{:keys [db]} [_ usuario senha]]
{:db (assoc db :opcoes-dialogo {:dialogo-ativo :carregando
:titulo "AGUARDE !!!"
:tipo :normal
:mensagem "Validando credenciais ..."
})
:http-xhrio {:method :get
:uri "/login"
:params {:usuario usuario :senha senha}
:format (ajax/url-request-format)
:response-format (ajax/json-response-format {:keywords? true})
:on-success [:login-ok]
:on-failure [:login-erro]}
}))
Then in /login
I´m returning a JSON that contains ok or error for user and password validation. When ok, I set into session the value for authenticate 'ok' in response from server. Is there any way to see session :authenticate 'ok' in :on-sucess callback?@fabrao, I’m not sure I understand the question. Do you want to read the json? What about the following?
(re-frame/reg-event-db
:login-ok
(fn [db [_ result]]
;; do whatever you want with the result here
;; like (assoc db :authenticate (:authenticate result))
))
https://github.com/Day8/re-frame/blob/master/docs/Talking-To-Servers.md#successful-get
no, wrong link, here is the right one: https://github.com/Day8/re-frame-http-fx#step-3-handlers-for-on-success-and-on-failure
that link above (the right one) should help you. basically, the result is passed into the :on-success
handler as the last parameter
the question is probably about reading a response header when :response-format
is set to ajax/json-response-format
I asked a question in off-topic which is related to re-frame, so I link it here too. https://clojurians.slack.com/archives/C03RZGPG3/p1496177736706470
@jfntn we're looking into it. Stu will create a ticket
@kirked context
is created fresh each event
@isnape the discussion here may help clarify https://github.com/Day8/re-frame/issues/255#issuecomment-274303581
@fabrao, apparently, there is no easy answer, look into cljs-ajax interceptors: https://github.com/JulianBirch/cljs-ajax/blob/master/docs/interceptors.md
@mikethompson cool, thanks for the update, running async works for now
@jfntn there's work currently happening on a branch, which we hope to release in the next couple of days