Fork me on GitHub
#om
<
2016-10-11
>
steveb8n08:10:20

@anmonteiro I think I have hit a bug in om server side denormalization. Could you confirm that I am not mistaken? I’ll log an issue as soon as I know it’s not my brain that has a bug. https://gist.github.com/stevebuik/665511e028295f422ce21f2596b77c3a

anmonteiro09:10:17

@steveb8n: looks like a bug, but I don't have access to a computer right now to try it out

steveb8n09:10:47

ok thanks. I’ll create an issue. thanks for the verification. It’s not urgent for me, I can work around it

anmonteiro09:10:34

Does it work in ClojureScript?

steveb8n09:10:12

haven’t tried in cljs. will do that and will update the issue

anmonteiro09:10:39

@steveb8n: awesome, thanks. I'll take a look later

steveb8n13:10:09

@anmonteiro same in cljs. I have updated the gist and issue. https://github.com/omcljs/om/issues/802

anmonteiro13:10:48

@steveb8n thanks, looking into it now

Joe R. Smith15:10:17

Good morning! If I’m performing a mutation followed by a read in a transaction (against my server) and the mutation stores something in datomic, is there a way to shuttle the new db value along to the next (in this case, read) parser method? Looking at the implementation of the parser step function, there doesn’t seem to be any accumulation of results visible to each mutate/read parser method.

Joe R. Smith15:10:53

specifically, I’m using pedestal and my only option right now is to acquire a new DB value, which is suboptimal bc concurrency + consistency + independent read impls that can be composed in various ways. 😄

anmonteiro15:10:02

@solussd so this is on the server right?

anmonteiro15:10:37

since you call the parser directly in your server handler with the mutation, you can add a key to env which represents the DB value

anmonteiro15:10:22

let’s say it’s an atom or a volatile. Whenever you perform the mutation, you can swap! that key with the db-after and have it available in the read

Joe R. Smith15:10:23

but env is closed over by the step function- not accumulating values as the reduction progresses

anmonteiro15:10:52

@solussd wouldn’t that work?

Joe R. Smith15:10:02

yes, it would, though it feels a little hacky.

anmonteiro15:10:23

It does feel a little hacky 🙂

jfntn15:10:23

I've used a similar solution for handling dependent mutations on the remote, it's worked well

Joe R. Smith15:10:33

but then, I can’t think of a reasonable way to merge mutation action fn results at each step

anmonteiro15:10:06

I don’t even know that would be desirable

anmonteiro15:10:32

it would be good for your use case, but maybe not for others where you want to perform mutations in “isolation"

peeja18:10:45

Maybe it would make sense for the parser to carry both the state reference and the immutable state value in the env, and then use the return value of the action as the new state value for the next key

peeja18:10:08

I've always thought it was odd to have to deref the state in a read anyhow

peeja18:10:27

Oh, I see, does the parser currently collect the actions before running any of them?

anmonteiro19:10:01

@peeja I don’t think so, it runs them as it sees them

peeja19:10:14

Ah, then that could work, right?

anmonteiro19:10:11

yeah, but at what cost?

anmonteiro19:10:43

then mutations and reads wouldn’t really have the same “interface” (in reads the state wouldn’t be an atom)

anmonteiro19:10:59

that has been a goal since the beginning

peeja19:10:04

Right, I'm saying they both get both

anmonteiro19:10:15

OK so then what for?

anmonteiro19:10:23

you can get one by derefing the other

peeja19:10:35

Everyone gets the connection/atom, as well as the current value

peeja19:10:41

You can't, though, not in datomic

anmonteiro19:10:04

oh you’re speaking about the server

peeja19:10:16

Getting the latest db from the connection isn't necessarily the same as the db you got from your last transaction

peeja19:10:34

Yeah, it's only necessary on the server, but only because JS is single-threaded

peeja19:10:42

but it makes sense for both, I think

anmonteiro19:10:57

Yeah I get it, I was confusing things

anmonteiro19:10:09

I can see how that would be useful

anmonteiro19:10:53

but: it’s possible to solve in userland and would probably introduce Datomic-specific code

anmonteiro19:10:05

not something you can reuse if you’re talking to other DBs

peeja19:10:07

I've always thought that derefing the state for each key felt weird, and that you should only really deref it at the start, in the case of all-reads

peeja19:10:23

Shouldn't be Datomic-specific

peeja19:10:47

If you expect the result of the action to be the new state value, that works in any system

anmonteiro19:10:25

no that’s not right

peeja19:10:31

(You still need to define how you get the value from the state reference at the beginning, but that seems doable)

anmonteiro19:10:55

there can be no result from an action

anmonteiro19:10:03

you can do a mutation for side-effects only

anmonteiro19:10:20

and what’s the “app state” in the server?

anmonteiro19:10:30

in Datomic I can see it could be a database

peeja19:10:31

The db value

peeja19:10:38

Right, it doesn't necessarily exist

anmonteiro19:10:41

but if you’re using other DBs, you’ve only got a connection

peeja19:10:45

but you don't need to do it this way

peeja19:10:58

It would be backwards compatible with the current way

peeja19:10:57

I'm saying it would be nice for Om to take advantage of immutable DB values when you have them, such as in Datomic, and with either the default DB format or Datascript

anmonteiro19:10:01

just minor refactoring & an added invariant

dnolen19:10:50

@anmonteiro yes will get to those later