Created
April 24, 2014 20:20
-
-
Save favila/11268240 to your computer and use it in GitHub Desktop.
Hack to fit tempids into JS int range for storefront.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def ^:const SIGN-BIT (bit-shift-left 1 63)) | |
(defn tempid-cljs->clj [tid] | |
(if (neg? tid) | |
(let [cljtid (-> tid (-) (bit-or SIGN-BIT))] | |
(d/tempid (d/part cljtid) (d/tx->t cljtid))) | |
tid)) | |
(defn tempid-clj->cljs [tid] | |
(if (neg? tid) | |
(-> tid (bit-xor SIGN-BIT) (-)) | |
tid)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment