Fork me on GitHub

@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.


I think oauth is not too different


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:

 (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 had also considered something like :projects {:some-name {…}, :some-woof {...} }


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.


just a hypothesis


@negaduck the api call is super simple:

 (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)]
     :gap "1em"
     :children [[somethings]])


I think that’s whats happening


@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’d check if it also sends ajax requests continuously along with that println.


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


I very much agree with that. I just don’t know where else this would belong


@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


well, you don’t need cofx, just reuse that :http-xhrio part


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


what struggles?


ah okay, also ClojureScript and more generally


@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!