Fork me on GitHub
#reagent
<
2017-07-14
>
pesterhazy08:07:22

What are the options of state management for reagent?

pesterhazy08:07:16

I know re-frame, keechma, petrol, "simply use swap, what else do you need?" and "roll your own"

pesterhazy08:07:48

I guess you could use re-frame only for processing actions, ignoring the subscriptions?

pesterhazy09:07:54

added to the gist

metametadata10:07:08

@pesterhazy I also update this list from time to time, but not every lib is strictly about Reagent: https://metametadata.github.io/carry/faq/#what-are-the-alternative-clojurescript-frameworks

pesterhazy10:07:18

cool - you're right, state management doesn't have to be about reagent at all

joshkh12:07:16

is there a way to get the HTML string from a react component? (fn bootstra-popover-content [] (fn [content] [:div content])) => <div...

joshkh12:07:06

you're the man! (presumably)

fedreg16:07:31

Hi all, I’m getting an error Error: Assert failed: Invalid tag: 'F#' (in tabber.core.Chords) when trying to perform (map #(str/split % #"/") song) on ... F#/m7/4 .... It is a music app so I need to be able to use # but any chord that uses it throws an error. Any way to escape that? Never had this error in React or any other language so not sure how to proceed. thx!

fedreg16:07:41

Here is the trace if that helps

(defn parse-tag [hiccup-tag]
  (let [[tag id class] (->> hiccup-tag name (re-matches re-tag) next)
        class (when-not (nil? class)
                (string/replace class #"\." " "))]
    (assert tag (str "Invalid tag: '" hiccup-tag "'"
                     (comp/comp-name)))
    #js{:name tag
        :id id
        :className class}))

pesterhazy16:07:29

you're usiing F# as a component - that seems wrong

fedreg16:07:32

@pesterhazy hmmm. I’m just converting a long string of a/b/c a/b/c a/b/c to a list of ( ["a" "b" "c"] ["a" "b" "c"] ...) that is then being fed into a component but as for using F# as a component…. it is used the same as all other characters without a trailing # and those have no error. Seems to be how the # is being interpreted.

noisesmith16:07:40

the first element of a vector is treated as a component or tag

noisesmith16:07:59

perhaps you want to start off the vector with something like :span before the note strings

fedreg16:07:22

@noisesmith Oh I see… Sorry @pesterhazy didn’t catch that meaning. But why do I have no problem with all the other notes with no #? I can’t really add a span in front of these because I’m using them as strings. I can rework my solution but I’d like to udnerstand why I’m having the issue since it is likely to come up again. thx

pesterhazy16:07:30

I wouldn't think about "what is different?" but "why is it blowing up?" - you must be doing something fishy there. But we can't see that because it's not in the snippet you posted

fedreg16:07:43

It is this long chain that surely needs refactoring

as-> songInfo song
        (first song)
        (drop 2 song)
        (map #(str/split % #" ") song)
        (apply concat song)
        (filter #(not (str/blank? %)) song)
        (map #(str/split % #"/") song)
        (cons ["X" "X" "4"] song)
        (swap! state/app-state assoc-in [:song] song)))

noisesmith16:07:41

the map / apply concat lines can be replaced with (mapcat #(str/split % #" ") song)

pesterhazy16:07:31

something ends up as the first element of a vector which is interpreted by reagent as a component

fedreg16:07:20

@pesterhazy Ok, I’ll trace everything through and see what I’m doing. Still at the hacking stuff together phase of learning. Thanks for the help

fedreg17:07:56

@pesterhazy I was displaying the final transformed data in my view for debugging and sure enough, that was the issue. Thanks again.