-
Notifications
You must be signed in to change notification settings - Fork 27
Observable Collection Ideas
aaronc edited this page Nov 8, 2014
·
5 revisions
Every change notification is a vector consisting of vectors representing the individual changes.
Insertion/updates
[unique-key map-of-key-value-pairs]
Deletions/retractions
[unique-key nil]
[unique-key {:key-to-retract nil}]
[unique-key :key-to-retract]
[unique-key [& keys-to-retract]]
Try modeling after something similar to Datomic.
Example:
(transact! coll [unique-key map-of-key-value-pairs])
(transact! coll map-of-key-value-pairs)
;; Retractions
(transact! coll [:unique-key nil])
(transact! coll :unique-key)
Transaction data:
(defalias UpdateOrInsert (U (HMap) (HVec [Keyword (HMap)]))
(defalias Retraction (U Keyword (HVec [Keyword]))
(defalias PropertyRetraction (HVec [Keyword (U Keyword (HVec [Keyword]))]))
(defalias TxAtom (U Retraction UpdateOrInsert))
(defalias TxData (U TxAtom (Vec TxAtom)))
Or maybe something simpler:
(defalias UpdateOrInsert (HVec [Keyword (HMap)]))
;; or
(defalias UpdateOrInsert (HMap))
(defalias Retraction (HVec [Keyword nil])
(defalias PropertyRetraction (HVec [Keyword (Vec Keyword)])) ;; can also be done by setting null values in UpdateOrInsert
(defalias TxData (U UpdateOrInsert Retraction PropertyRetraction))
(defn transact! [coll & tx-data])