reagent-project / reagent

A minimalistic ClojureScript interface to React.js
http://reagent-project.github.io/
MIT License
4.74k stars 412 forks source link

Refactor Reaction type to clarify when things “change” #577

Closed shaunlebron closed 1 year ago

shaunlebron commented 1 year ago

After having trouble understanding all the branches inside the Reaction Deref function, I pulled the notify-deref-watcher! before the dirty check, so we can combine both dirty checks. Please verify that this is equivalent and easier to follow!

shaunlebron commented 1 year ago

Also, @holmsand, could you explain the purpose of this branch?

(if (and non-reactive (nil? auto-run))  ;; <-- what exactly does this mean?
  …
  (._run …))

edit: nevermind, it makes sense now. I refactored this to use an affirmative condition. deref only uses _run in a reactive context or when auto-run is set:

(if (or (reactive?) auto-run)
  (._run …)
  …)
shaunlebron commented 1 year ago

I’ll start a new PR to clarify these extra changes. (Moved to #578)