GithubHelp home page GithubHelp logo

Comments (4)

bhauman avatar bhauman commented on August 22, 2024

This is an interesting one.
I'm wondering what the behavior should be.

Here is a solution in the meantime:

(def render  (fn [state node]
      (set! (.-innerHTML node) (str "Click me count: " (:count @state)))
      (set! (.-onclick node) #(swap! state update-in [:count] inc))))) 

(defn render-on-change [render-fn] 
   (fn [state node]
        (add-watch state :rendering (fn [_ _ _ _] (render-fn state node)) ;; idempotent
        (render-fn state node)))

(defcard dom-node-updating
  "Seems dom-node doesn't update?"
  (dom-node (render-on-change render)
  {:count 0}
  {:inspect-data true})

The parens may be wrong, this is just a quick sketch.

from devcards.

fdserr avatar fdserr commented on August 22, 2024

Thanks much, that should do the trick for now.

from devcards.

exupero avatar exupero commented on August 22, 2024

I ran into this too and came up with a similar solution, but I also notice that the history controls don't appear when the state first changes. They show up after I save the file and Figwheel reloads or make a second state change.

from devcards.

bhauman avatar bhauman commented on August 22, 2024

good point, that makes sense

On Fri, Oct 23, 2015 at 7:28 AM, Eric Shull [email protected]
wrote:

I ran into this too and came up with a similar solution, but I also notice
that the history controls don't appear when the state changes. They only
show up after I save the file and Figwheel reloads.


Reply to this email directly or view it on GitHub
#48 (comment).

from devcards.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.