Last active
December 15, 2018 04:44
-
-
Save mfikes/122814757fd1f2aec9de509446793e5f to your computer and use it in GitHub Desktop.
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
cljs.user=> (def metas (atom {})) | |
#'cljs.user/metas | |
cljs.user=> (extend-type object | |
#_=> IWithMeta | |
#_=> (-with-meta [o meta] | |
#_=> (swap! metas assoc (goog/getUid o) meta) | |
#_=> o)) | |
nil | |
cljs.user=> (extend-type object | |
#_=> IMeta | |
#_=> (-meta [o] (when (goog/hasUid o) | |
#_=> (@metas (goog/getUid o))))) | |
nil | |
cljs.user=> (def o #js {:a 1}) | |
#'cljs.user/o | |
cljs.user=> (with-meta o {:b 3}) | |
#js {:a 1, :closure_uid_857478408 17} | |
cljs.user=> (meta *1) | |
{:b 3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Or just cram the meta in the object to tie its life to the object: