Fork me on GitHub
#clojurescript
<
2017-11-30
>
boldaslove15600:11:22

Anybody knows how to attach transaction data from datomic to datascript?

tbaldridge01:11:14

In Datomic, transactions are entities like everything else, they just get created with unique ids

tbaldridge01:11:33

But I’d need more info to know how to help you

boldaslove15601:11:34

@tbaldridge Basically I have a :tx-data from tx-report then I transform it such that it suitable for datascript to consume [[:db/add 132132132 :user/name "foobar"]]

boldaslove15601:11:29

Datomic allows me to explicitly set the :db/txInstant , so [[:db/add 132132132 :user/name "foobar" 111111111] [:db/add 111111111 :db/txInstant "current date" 111111111]]

boldaslove15601:11:16

While Datascript can't. It just overrides the transaction id with :db/current-tx . What I'm trying to do is to clone transaction to datascript

tbaldridge01:11:30

oh I see, yeah, I don't think Datascript has any support for transactions at all, what with it not supporting history

tbaldridge01:11:40

one of my biggest issues with the library, it tries to copy Datomic, but just completely ignores some of the better features. It ends up creating a bit of a impedance mis-match

boldaslove15601:11:11

So it's not doable in the current state then

tbaldridge01:11:45

Yeah, I don't think it is. You might be able to hack something in via an extra attribute on every entity, but that's a bit icky

notduncansmith01:11:04

@boldaslove156 you are reading from a queue of raw transaction reports on the frontend? It sounds like what you may want is a reduce on those into whatever data structures you need to query from the UI.

tbaldridge01:11:49

Problem is, Datomic tracks time, data script doesn’t

tbaldridge01:11:59

So if you need time, you’re hosed

notduncansmith01:11:20

Could you realistically rely on them being delivered in-order within a certain window?

boldaslove15601:11:56

Yes I was, and I succeed it to the extent I can have somewhat of a copy of datomic in datascript

boldaslove15601:11:11

Except the transaction id

boldaslove15602:11:39

I'm not sure about that, but I think it won't be a problem even if the order is messed up, since the date is generated by datomic

boldaslove15602:11:31

Maybe in the current state I just have to add datascript specific datom about datomic transaction id just like @tbaldridge suggests

notduncansmith02:11:20

You may also want to check out the https://github.com/metasoarous/datsync library (includes "Translate ids between Datomic and DataScript in transaction flow" as a feature)

Niki09:11:12

Just copy my response from #datascript here:

Niki09:11:28

DataScript does not let you change transaction id, but you can set any attrs on each transactions to any values you want

Niki09:11:59

(d/transact! conn
  [[:db/add e :attr v]
   [:db/add :db/current-tx :db/txInstant (js/Date.)]
   [:db/add :db/current-tx :original-datomic-tx-id 11111111]])

roti11:11:34

Hi, I'm having a problem in om.next which drives me crazy. 🙂 Namely my view is not being rendered at all as soon as the root comonent implements om/IQuery, and I can't figure out why. When I comment the IQuery part, everything is ok, but as soon as I put it back, my view is not rendered at all (with no errors & co). Did anybody encounter this issue?

roti11:11:24

I get the feeling that the initial rendering is actually not done

roti11:11:56

I found the problem: initial data was null, therefore the initial rendering is not happening 🙂

mikerod19:11:42

Cross post from #cljsjs since it may be a more general question: If I’m trying to override the provided deps.cljs file from a cljsjs jar, is there a way I can still use the :file in :foreign-libs compiler opt to refer to the file within the jar? e.g.

{:file "cljsjs/project/development/project.inc.js"
 :file-min "cljsjs/project/production/project.min.inc.js"
 :provides ["cljsjs.project"]
 :requires ["things.here"]}
I get file not found doing it this way. It seems to try to form an absolute file path based on my project root.

noisesmith19:11:43

generally with the jvm you can’t use things in jars as if they were files, the apis don’t generalize on that level, and File is not the generic thing

mikerod19:11:47

It’s odd to me. A cljsjs dependency jar will refer to its :file in this way

mikerod19:11:06

and so far, I haven’t seen any special handling of where the :foreign-libs entry comes from

mikerod19:11:14

still reading through it to try to understand what is going on

noisesmith19:11:52

@mikerod yeah - that could be the case, I was only talking about the general thing and I don’t know exactly how :file works in cljs maps

symbit21:11:15

Hello, how do you convert $(‘#grid’).w2grid({name:’grid’, ...}); hopefully without jquery. Has anyone used w2ui from ClojureScript? I don’t see any cljsjs for w2ui yet. Referring to http://w2ui.com/web/demo/grid Thx.

noisesmith21:11:43

@symbit

(ins)dev:cljs.user=> (require '[goog.object :as gob])
nil
(ins)dev:cljs.user=> (gob/get #js{:#grid "OK"} "#grid")
"OK"
so something like (-> js/$ (gob/get "#grid") (.w2grid #js{:name "grid" ...}))

noisesmith21:11:57

without jquery is another question of course

qqq21:11:36

I want to write:

var div = goog.dom.createDom('div');
goog.dom.setProperties(div, {
    'style': 'background-color: red',
    'class': 'div-class',
    'id': 'container'
});
I'm writing:
(defn foobar []
  (let [svg-dom  (gdom/getElement "app") 
        svg-text (.createElementNS js/document "" "text")] 
    (removeAllChilds svg-dom)
    (.appendChild svg-dom svg-text) 
    (.setProperties svg-text (clj->js {"x" 20 "y" 20}))))
I think there is something wrong with the .setProperties and clj->js

thheller22:11:22

just write #js {:x 20 :y 20} directly instead. .setProperties is not a native dom fn, use gdom/setProperties instead