Fork me on GitHub
#re-frame
<
2018-07-24
>
Jp Soares10:07:15

Is anyone using http://www.webcomponents.org with clojurescript? I tested importing one component and it seems that different components might need different ways to import. Are there some known issues or tips for using them with re-frame?

lepistane11:07:03

one question, i am using sente+re-frame and in my handler

(defmethod -event-msg-handler :bus-line/coord
  [{:as ev-msg :keys [?data]}]
  (do (println "Push coord from server: %s" ?data)
      (rf/dispatch [:bus-line/coord (:coord ?data)])))
this dispatch just doesn't work println does get triggered but dispatch doesnt but it works if i eval it what am i missing? why doesn't it work

Sen12:07:17

Did you try to print the exact (:coord ?data) as you have it in dispatch? Just guessing maybe there is nothing

lepistane12:07:05

yes i did

Push event from server: %s [:bus-line/coord {:what-is-this An async broadcast pushed from server, :how-often Every 10 seconds, :to-whom c9ff25d9-9579-43f2-9477-06ea68855ca9, :coord {:bus-line string, :current-lat string, :current-long string, :timestamp 2}, :i 52}]

lepistane12:07:14

notice line above dispatch - there is println

Sen12:07:33

Yes, however, there you print only ?data, not (:coord ?data)

lepistane12:07:03

there is key coord in line printed and it contains

:coord {:bus-line string, :current-lat string, :current-long string, :timestamp 2}, :i 52}

Sen12:07:03

But I see

Sen13:07:12

Try it like this #(rf/dispatch [:bus-line/coord (:coord ?data)])

lepistane13:07:30

alright, i doubt that will work. but that was an issue before to be honest i didnt use # on function call in on-click

lepistane13:07:24

nop - same behavior

Sen13:07:38

Yeah, that's why I suggested it, I had the same with on-click. Weird, no idea then, maybe someone with more knowledge can help. My last guess is maybe dispatch behaves differently in defmethod for some reason.

lepistane13:07:45

i saw other examples online that use it like this and it works there but those were from 2016.. hopefully someone answers

felbit14:07:31

I try to build a simple “create an account and login” workflow with re-frame and a very simple luminus-powered-backend. This seems remarkably hard to accomplish. I might do this fundamentally wrong. Is there any good resource on this topic somewhere on the web? (also posted in #luminus)

lepistane14:07:18

https://github.com/StankovicMarko/invoices/ i think i have flow here luminus+re-frame with completed register /login

felbit14:07:16

btw. my still-not-working code to get the registration working is about 140 LOC while a (working) Reagent-only implementation of the same process is about 37 LOC. Is that expected?

felbit14:07:38

@U45SLGVHV Thank you very much!

lepistane14:07:27

140 might be bit much but re-frame has more code true but really keeps you sane i remember developing my first app using reagent it got really messy toward the end cause i didn't have awareness of handling atoms gracefully re-frame does that for you and it is helpful in that regard for bigger applications small hobby like projects - reagent might be better choice

felbit14:07:16

I see. Your code here matches almost exactly my Reagent only implementation - with just a little re-frame sugar on top. I might have done it way to complicated, implementing a state machine. 😄

lepistane14:07:40

yea, my implementation is not very re-framy but it gets you going later you can improve like use re-frame reg-fx instead of reg-event etc etc

felbit15:07:02

Thanks again. First time I feel like a beginner in years building this stuff. Like I know nothing about programming …

kennytilton16:07:43

@U45SLGVHV I ported an elaborate web app from JS to re-frame and reagent as a way of exploring them and found reagent simpler, but to your point, I have been hacking away with my own reactive library for decades. Along the way I had an epiphany that ratom programming might not seem so natural to normal people. 🙂 I am thinking about blogging up an intro to the paradigm so your experience sounds very relevant. Can you share more, here or by DM?

lepistane16:07:15

i can share more sure 😄 what are u interested in? sorry in advance i am little bit out of it very busy day today brain is at 20% 😄 if u got any questions i will send answers just little bit later @U0PUGPSFR

kennytilton16:07:51

OK, asynchronous communication is always the best. You mentioned perhaps not “handling atoms gracefully”, and sth. about at a smaller scale it was OK. I guess my first Q would be how deep did you go with atoms? I just refreshed my memory on my own app and saw vanilla derefs, then cursors, then track. Did you get into all that or more?

lepistane12:07:35

to answer your question @U0PUGPSFR i just felt that there is and should be better way of dealing with atoms than what i was doing. i did use derefs and bunch of atoms, i had 1 that is app state but then almost an atom for each component/view to handle errors or async data. don't remember using cursors and track. there was no need for them... hmm maybe there was but i didn't get to use them i know that once i saw reframe the flow of information and the way i was doing things in reagent were pretty much the same in re-frame i just didn't have to think about atom, it's state i was pretty easy to switch. thought i should mention i am not using re-frame the 'right' way meaning - all conventions but i am learning as i go

kennytilton13:07:39

This reminds me of what Mike wrote in the FAQ about “why not just use reagent?” — the ad hoc solutions we would inevitably invent will prolly not be better than re-frame, so we can save ourselves the trouble. In your case it sounds like you did not get as far as developing your own re-usable framework before discovering re-frame and realizing it would save you a lot of wheel-reinvention. I can definitely see how an ad hoc approach to organizing ratoms could get “interesting” fast. 🙂

lepistane13:07:41

yea that's true

kennytilton14:07:40

As an aside, ratoms are great for async. Shoot that request out and whenever it comes back, bam, straight into the model it flows. Thx for the insight into your experience.

lwhorton13:07:03

i have a couple anecdotal cases where reagent-only projects very quickly turned into a poor-man’s reframe. the event driven model just fits so well to UI work that you will end up somewhere similar quite often. in that case, might as well use reframe which really does have some fantastic concepts, tooling, extensibility, docs, etc.