re-frame

https://github.com/Day8/re-frame/blob/master/docs/README.md https://github.com/Day8/re-frame/blob/master/docs/External-Resources.md
Александр Стоянов 2020-10-27T00:38:53.242200Z

Hello! I'm learning clojurescript now and have some problem: (def click-count (atom 0)) (defn b [] [:div "The atom " [:code "click-count"] " has value: " @click-count ". " [:input {:type "button" :value "Click me!" :on-click #(swap! click-count inc)}]]) in main-panel: (b) So that's almost work. I have button on my page but it doesn't refresh. First value is 0 and when i click on button value don't changes. It changes only when i clicked some times then re-build it and it shows quantity of clicks. So what i should do to refresh it without re-building?

p-himik 2020-10-27T00:55:29.242400Z

Replace (b) with [b]. Unrelated things: - Your code has nothing to do with re-frame - it would be better to ask the question in #reagent - You can use triple backticks to create whole code blocks

p-himik 2020-10-27T00:57:36.242700Z

If you use triple backticks as first and last lines of your code, you will get something that looks like this:

(defn x[]
  (println "x"))

Александр Стоянов 2020-10-27T04:28:47.247300Z

Replacing doesn't help. What it may be else?

lsenjov 2020-10-27T06:46:41.247500Z

You need to use a reagent/atom, not a cljs atom

lsenjov 2020-10-27T06:47:21.247700Z

Oh, someone answered this in #reagent already, excellent

2020-10-27T13:02:06.251200Z

would anyone have some recommendations to add syntax highlighting in a preblock in a reframe app?

joshkh 2020-10-27T13:12:55.251300Z

i don't think that's re-frame specific, but you can checkout highlight.js https://ask.clojure.org/index.php/9068/how-to-use-highlight-js-in-a-shadow-cljs-project

joshkh 2020-10-27T13:13:40.251600Z

the trick there is to call the highlight function after the reagent component has been rendered

joshkh 2020-10-27T13:14:32.251800Z

and if you're using shadow-cljs then you can probably easily import this node module and use highlight js as a react component https://github.com/bvaughn/react-highlight.js/

kennytilton 2020-10-27T15:49:45.256400Z

This seems like a simple problem for re-frame, but I am stumped. I want to determine if a field has changed when the user tabs off it, but not before. So if they make a change and then immediately change it back to what it was before leaving the field, I need to recognize that in its final form it is unchanged. Unfortunately, this is a "new item" form so I have no existing source of truth against which to compare. Is there a simple solution I am missing? Thx!

kennytilton 2020-10-28T14:28:50.262100Z

Yep, that is the way we are going. I just had a bug loading the prior value into app-db, and my re-frame is rusty enough that I thought the whole approach was in vain. We spotted the bug and are in good shape now. Thx! @mikethompson

kennytilton 2020-10-27T15:55:21.256500Z

I realize this in part an issue with ReactJS which always wants the form to correspond to app state, IIUC.

p-himik 2020-10-27T16:22:40.256700Z

By "tab out", do you mean losing focus? If so, you can use the :on-blur event handler.

p-himik 2020-10-27T16:22:56.256900Z

It's more related to Reagent/React/JS than to re-frame.

kennytilton 2020-10-27T16:32:28.257100Z

Thx, @p-himik! Yeah, I am in the on-blur to avoid the hyperactive on-change handler, but I cannot tell if we have a net change from any on-change events. Playing with a vanilla atom now, but it feels ugly. 🙂 Yep, definitely a React issue at bottom. I hear they are moving away from imposing their own events scheme, btw.

p-himik 2020-10-27T16:33:34.257300Z

Ah, I see what you mean. Yeah, I think you will have to store the original value somewhere. Not necessarily an atom.

1👍
seqable 2020-10-27T17:43:56.257500Z

use :ref, then querySelectorAll on ref and doseq over resulting elems