Fork me on GitHub
#cljsrn
<
2017-10-19
>
yenda16:10:34

Has anyone been able to successfully use latest versions of realm ? All exemples I could find including our app are using 0.14.3 or earlier. In latest versions (e.g 2.0.0) the queries return something of type #object[Function] which pretty-prints to #object[Object [object RealmObject]]. The result is that previous js->clj was working and now it throws:

#object[TypeError TypeError: Type error]
[email protected][native code]
[email protected][native code]
cljs$core$IFn$_invoke$arity$1
cljs$core$type__GT_str
Any idea how to read that RealmObject into cljs ?

yenda16:10:44

came up with this for now:

(defn js-object->clj [js-object]
  (if (= (goog/typeOf js-object) "object")
    (reduce (fn [acc k]
              (assoc acc (keyword k) (js-object->clj (aget js-object k))))
            {}
            (.keys js/Object js-object))
    js-object))