This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-20
Channels
- # arachne (4)
- # bangalore-clj (1)
- # beginners (38)
- # boot (182)
- # cider (21)
- # cljs-dev (9)
- # clojars (5)
- # clojure (229)
- # clojure-austin (1)
- # clojure-berlin (1)
- # clojure-czech (3)
- # clojure-dusseldorf (3)
- # clojure-ireland (5)
- # clojure-italy (4)
- # clojure-russia (33)
- # clojure-spec (73)
- # clojure-taiwan (6)
- # clojure-uk (22)
- # clojure-ukraine (1)
- # clojurescript (80)
- # core-async (26)
- # cursive (3)
- # datascript (20)
- # datomic (9)
- # defnpodcast (8)
- # editors (4)
- # emacs (7)
- # garden (41)
- # hoplon (2)
- # java (1)
- # lambdaisland (2)
- # lein-figwheel (1)
- # leiningen (5)
- # luminus (4)
- # lumo (36)
- # off-topic (4)
- # om (21)
- # onyx (1)
- # pedestal (33)
- # re-frame (33)
- # ring-swagger (70)
- # spacemacs (26)
- # specter (7)
- # sql (6)
- # timbre (2)
- # untangled (12)
- # vim (3)
- # yada (1)
@markel, I did auth with openid connect, and it had little to do with re-frame, because the main part is opening a pop-up with authorization request. Then after all redirects you should land to a page which calls some code from your app: window.opener.your_project_name.core.dispatch_login('{{ id }}’);
and then closes itself.
Hey all… I’m running into something interesting and I was hoping someone could explainw hy I’m seeing this. My db atom has a key :projects
. Projects is a collection of maps, as such. [{:name “some-name” :other-field “somefield”} {:name “some-woof” :other-field “somewoof”}]
Sometimes I detect a change to one of the projects
and as a result make an api call to fetch the new one. This is where my issue raises it’s head. I cannot think of a nice way to update the specific project
map I want with the result of my api call and as a result I have to do something like this:
(re-frame/reg-event-db
:good-get-project
(fn [db [_ project-name result]]
(let [project (util/find-project-by-name project-name (:projects db))]
(println "moo")
(update db :projects #(do (remove #{project} (:projects db))
(merge % result))))))
Now when I run this. Something weird happens. moo
gets printed to my repl continuously until I leave that page. Can anyone tell me why?@petr, I’m not sure, where does the api call happen? And what about having your projects in a map instead of a vector, like :projects {:name “some name” {:its-properties :etc} :name “some-woof” {…}}
and then update them using update-in
?
@negaduck That is something I had considered. I’m not in love with it but would do it if it came down to it. I’m very confused as to why it seems to be in a loop. Does it have to do with the view having a subscription to the :project
key of the db?
I don’t see the api call, and how you detect changes on one of projects. It could be detecting a change, firing an update, then detecting it again and firing an update, etc, recursively.
@negaduck the api call is super simple:
(re-frame/reg-event-fx
:http-get-project
(fn [{:keys [db]} [_ job-name]]
{:db (assoc db :show-twirly true)
:http-xhrio {:method :get
:uri (str " " job-name)
:timeout 8000
:response-format (ajax/json-response-format {:keywords? true})
:on-success [:good-get-projects]
:on-failure [:bad-http-result]}}))
It is called as such on the view:
(let [project-title @(re-frame/subscribe [:params])
_ (re-frame/dispatch [:http-get-project project-title])
projects @(re-frame/subscribe [:projects])
project (util/find-project-by-name project-title projects)]
[re-com/v-box
:gap "1em"
:children [[somethings]])
@petr, Can it be the following? When you are subscribed to project-title, when it changes, you fire an ajax request that again triggers update of project-title.
I think this is because your view isn’t pure function, it dispatches events, and it shouldn’t
@negaduck I think this is because your view isn’t pure function, it dispatches events, and it shouldn’t
. I’d love to know the correct pattern for doing this
@petr, views should be pure functions of app state, like v = f(s)
, you are almost there, just put that dispatch out of your view somewhere. You could also reg-cofx to use it in :init-db event
hey everybody
I'm doing research for a re-frame course
I'd love your input
it's a quick survey about your struggles with re-frame
@ericnormand personally i don't like how you have phrased your money questions. I appreciate what you're doing but as one data point, I find it hard to evaluate that in advance of seeing what your solution is and I can't imagine all the possible solutions (even in course form) to my 'frustration'. Is a course/video even a good answer to those. It seems backwards to me. But, as I say, just one mans data.
Thanks for the data point
do you have any frustrations with re-frame?
how much would it be worth to you to get rid of them?
that's all I'm asking
if you could ✨ make it go away, how much would you pay?
@ericnormand if you read through the history logs of this slack channel you should find a bunch of people's questions about re-frame which would be good to mine for course material
@ericnormand something about the "How much would be TOO EXPENSIVE to spend to solve your frustrations?" and subsequent questions rubbed me up the wrong way and made me bail on the questionnaire. if there was a magic wand and i could get the REALLY GOOD DEAL (and retain the knowledge) then i would certainly pay, were it feasible - but i'm not yet confident that the wand or deal even exist!