Fork me on GitHub
#datomic
<
2016-05-27
>
jamesnvc18:05:39

Is there a best practice around deref'ing datomic transactions? i.e. should I always deref d/transact so I get errors thrown, or will that be suboptimal?

bvulpes18:05:15

jamesnvc: i do

jamesnvc18:05:12

Any cases where it is better to not deref?

bvulpes19:05:03

i suppose when you don't care about seeing an error on the spot, or when you're okay running the transaction asynchronously

bvulpes19:05:17

"when you don't have to" i imagine would be the advice

Lambda/Sierra19:05:48

d/transact is actually synchronous, even though it returns a Promise, so you almost always want to deref it immediately.

jamesnvc19:05:39

stuartsierra: ah, good to know, thanks!

jamesnvc19:05:54

(I guess that would explain why transact-async exists

bvulpes19:05:56

huh. today i learned!

Lambda/Sierra19:05:00

Yes. d/transact-async is truly async, it returns immediately, so you can choose if / when you want to deref it.

Ben Kamphaus19:05:29

Note in the way the pipeline example here: http://docs.datomic.com/best-practices.html#pipeline-transactions - uses transact-async, we still deref to be alerted to errors and handle (in this case just closing channels and aborting, reporting the error).