Permalink
Browse files

Replace updated sequence items in UI tree

  • Loading branch information...
nblumoe committed Jan 19, 2017
1 parent b4cb512 commit 7ee92f4900cbb90b2a0728ef2a746ccdd2b15db1
Showing with 15 additions and 8 deletions.
  1. +3 −2 src/fn_fx/diff.clj
  2. +12 −6 src/fn_fx/fx_dom.clj
View
@@ -10,6 +10,7 @@
(set-child! [this parent id child])
(set-indexed-child! [this parent k idx child])
(delete-indexed-child! [this parent k idx child])
(replace-indexed-child! [this parent k idx child])
(set-property! [this node property value]))
(defquasitype Component [type dom-node props])
@@ -57,7 +58,7 @@
;; TODO: Unmount?
Created (set-indexed-child! dom parent-node k idx node)
Deleted (delete-indexed-child! dom parent-node k idx node)
Updated nil
Updated (replace-indexed-child! dom parent-node k idx node)
Noop nil)))))
(defn diff-component [dom dom-node spec-a spec-b]
@@ -93,7 +94,7 @@
[:val :val] (if (= a b)
(->Noop b)
(->Created b))
(->Updated b))
[:nil :val] (->Created b)
View
@@ -29,15 +29,21 @@
(set-indexed-child! [this parent k idx child]
(run-later
(let [^List lst (render-core/get-property (unwrap-promise parent) k)]
(assert (= idx (count lst)) "TODO: Implement this")
(.add lst (unwrap-promise child)))))
(let [^List lst (render-core/get-property (unwrap-promise parent) k)]
(.add lst idx (unwrap-promise child)))))
(delete-indexed-child! [this parent k idx child]
(run-later
(let [^List lst (render-core/get-property (unwrap-promise parent) k)]
(assert (= idx (dec (count lst))) "TODO: Implement this")
(.remove lst ^int idx))))
(let [^List lst (render-core/get-property (unwrap-promise parent) k)]
(.remove lst (unwrap-promise child)))))
(replace-indexed-child! [this parent k idx new-child]
(run-later
(let [^List lst (render-core/get-property (unwrap-promise parent) k)]
(doto lst
(.remove ^int idx)
(.add ^int idx (unwrap-promise new-child))))))
(delete-component! [this node]
nil))

0 comments on commit 7ee92f4

Please sign in to comment.