Skip to content

Commit

Permalink
get rid of react hitch warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dspiteself committed Jan 29, 2021
1 parent 39d79b3 commit 5d8e2d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/react_hitch/qui_tracker.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[hitch2.tx-manager.halting :as halting]
[react-hitch.curator.react-hook :as rh]
[react-hitch.scheduler :as sched]
[goog.object :as gobj]
[breeze.quiescent :as q]
[react-hitch.descriptor-specs :refer [react-hitcher-process-spec
react-hook-spec react-hooker
Expand All @@ -21,7 +22,7 @@
(defn forceUpdate [graph-value c]
(if (instance? hook-dtor c)
((:h c) (get graph-value (:dtor c) sched/LOADING))
(when (some? (.-__graph c))
(when (some? (gobj/get c "__graph"))
(.forceUpdate c)))
nil)

Expand Down Expand Up @@ -73,15 +74,15 @@

(defn flush-deps-on-unmount {:jsdoc ["@this {*}"]} []
(this-as c
(let [graph (.-__graph c)]
(vreset! (.-__currentdeps c) #{})
(let [graph (gobj/get c "__graph")]
(vreset! (gobj/get c "__currentdeps") #{})
(sched/queue-qui-tracker-command graph c))))

(defn hitchify-component! [c graph]
(when-not (some? (.-__graph c))
(set! (.-__graph c) graph)
(set! (.-__beforedeps c) (volatile! #{}))
(set! (.-__currentdeps c) (volatile! #{}))
(when-not (some? (gobj/get c "__graph"))
(gobj/set c "__graph" graph)
(gobj/set c "__beforedeps" (volatile! #{}))
(gobj/set c "__currentdeps" (volatile! #{}))
(if-some [old-unmount (.-componentWillUnmount c)]
(let [new-on-unmount (fn []
(this-as c
Expand All @@ -100,7 +101,7 @@
(render-fn value rtx services)
unresolved)
focus-descriptors (tx-manager/finish-tx! rtx)]
(vreset! (.-__currentdeps c) focus-descriptors)
(vreset! (gobj/get c "__currentdeps") focus-descriptors)
(sched/queue-qui-tracker-command graph c)
result))
([graph unresolved c render-fn value meta services]
Expand All @@ -111,7 +112,7 @@
(render-fn value rtx meta services)
unresolved)
focus-descriptors (tx-manager/finish-tx! rtx)]
(vreset! (.-__currentdeps c) focus-descriptors)
(vreset! (gobj/get c "__currentdeps") focus-descriptors)
(sched/queue-qui-tracker-command graph c)
result)))

Expand Down
9 changes: 5 additions & 4 deletions src/react_hitch/scheduler.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:import (goog.async run nextTick))
(:require cljsjs.react
cljsjs.react.dom
[goog.object :as gobj]
[hitch2.protocols.graph-manager :as graph-proto]
[react-hitch.curator.react-hook :as rh]
[react-hitch.descriptor-specs :refer [react-hooker]]))
Expand Down Expand Up @@ -36,14 +37,14 @@
(let [graph-value (graph-proto/-get-graph g)]
(reduce
(fn [_ [c descriptors]]
(vreset! (.-__beforedeps c) descriptors)
(vreset! (gobj/get c "__beforedeps") descriptors)
(when (and
(not-empty descriptors)
(every?
(fn [dtor]
(loaded? (get graph-value dtor LOADING)))
descriptors)
(some? (.-__graph c)))
(some? (gobj/get c "__graph")))
(.forceUpdate c)))
nil
quichanges)
Expand All @@ -61,8 +62,8 @@
(defn per-graph-change-hook-subs [{:keys [quichanges hookchanges]} g whole]
(let [quichanges (into []
(keep (fn [c]
(let [current @(.-__currentdeps c) ]
(when (not= current @(.-__beforedeps c))
(let [current @(gobj/get c "__currentdeps") ]
(when (not= current @(gobj/get c "__beforedeps"))
[c current]))))
(persistent! quichanges))
subs (persistent! hookchanges)]
Expand Down

0 comments on commit 5d8e2d7

Please sign in to comment.