From c36be5701812ed7209ef9df5c67e1a3bcbf02761 Mon Sep 17 00:00:00 2001 From: Richard Newman Date: Fri, 7 Oct 2016 16:07:41 -0700 Subject: [PATCH] Expose a 'tempid' function on transaction results, because JS object lookup doesn't work for TempIds. --- src/common/datomish/js.cljs | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/common/datomish/js.cljs b/src/common/datomish/js.cljs index 2a9710e0..fccb8b55 100644 --- a/src/common/datomish/js.cljs +++ b/src/common/datomish/js.cljs @@ -75,13 +75,20 @@ (try (let [tx-data (js->tx-data tx-data)] (go-promise clj->js - (let [tx-result (js to-return)] + + ;; The tempids map isn't enough for a JS caller to look up one of + ;; these objects, so we need a lookup function. + (aset jsified "tempid" (fn [t] (get tempids t))) + jsified))) (catch js/Error e (println "Error in transact:" e)))) @@ -103,7 +110,11 @@ :q (fn [find opts] (q (d/db c) find opts)) :close (fn [] (db/close-db db)) + ;; So you can generate keywords for binding in `:inputs`. + :keyword keyword + ;; Some helpers for testing the bridge. + :println (fn [& xs] (apply println xs)) :equal = :idx (fn [tempid] (:idx tempid)) :cljify cljify