This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-24
Channels
- # admin-announcements (2)
- # beginners (5)
- # boot (29)
- # cider (46)
- # cljsjs (1)
- # clojure (19)
- # clojure-quebec (1)
- # clojure-russia (73)
- # clojure-spec (30)
- # clojure-uk (23)
- # clojurescript (35)
- # datascript (12)
- # datomic (7)
- # emacs (26)
- # hoplon (168)
- # leiningen (7)
- # off-topic (2)
- # om (32)
- # perun (8)
- # protorepl (8)
- # ring (45)
- # specter (10)
- # test-check (2)
- # yada (6)
is there a pattern in om next for combining a remote mutation and a remote read as part of the same query expression?
e.g. if you call (om/transact! this ‘[(create-object) :list/objects])
on the client, is it sane to send the mutation and receive the full list of objects back in the response, including the newly-created object?
@mclarke: that’s how I’d do it. are you having any problems with that approach?
after all doing all of that in a single batched request is one of the reasons Om Next exists 🙂
i think i’m doing something wrong on the client then, since the full query isn’t being sent, just the mutation
the component i’m calling transact!
from has a query [{:apps/items (om/get-query Application)}]
, should the read argument to transact!
be just a keyword or can it be the full “fat” query
i thought i remembered reading om performs a lookup based on the keyword to generate the query for you, but that could be mistaken
@mclarke: yeah, just the keyword is enough. but I don’t think follow-on reads perform remote reads
i see - i was playing with (om/force)
as a way to trigger the second read, but didn’t have success with that either
is a follow-on read in transact! different from the combined “mutate & read” query that i’m trying to send to the remote?
e.g. maybe i should refactor to call (om/transact! this ‘[(create-object)])
and in the client-side mutate function somehow rewrite the query that is sent server-side from [(create-object)]
to [(create-object) {:list/objects [...]}]
or something similar
@mclarke: I think force
should work
actually the parser doesn’t seem to recognize it, I’ll have to look with more time
ah got it. if it did recognize force
, i think it would trigger a second network call to re-read the data after the mutate is sent server-side, correct?
(appreciate the help on this sunday, i’ve been banging my head against this for a while now :P)
@mclarke: I’m unsure if it would trigger a 2nd network call or batch both queries
@dnolen: in case you’re thinking about cutting a release with the recent fixes, I’d still like to get a fix in for #727 before that if you don’t mind
@anmonteiro: ok, will wait for that
thanks
@anmonteiro: looks like (om/force)
should generate the remote query i’m trying to build (something like [(create-object) :object/list]
that is sent to the backend server, despite the presence of existing cached data for :object/list
). maybe i’m using force wrong, but the behavior i’m seeing with alpha40 is that a call to transact!
with (om/force)
on the read key only includes the mutation and not the read in the remote query
e.g. calling this:
(om/transact! reconciler (vector ‘(create-object) (om/force :apps/items)))
@mclarke: right, as I said before, it doesn’t seem that the parser recognizes force
for reads, only mutations
let me check if there’s something you can override in the reconciler to provide the behavior you seek
nah, doesn’t seem like
makes sense, i thought it might work for both reads and mutates based on:
(parser/expr->ast (om/force :apps/items))
{:type :prop, :dispatch-key :apps/items, :key :apps/items, :target :remote}
but i must be looking at the wrong path@mclarke: actually it seems that your remote reads should be happening https://github.com/omcljs/om/blob/master/src/main/om/next.cljs#L888
so I’d bet on a problem in your parser?
@anmonteiro: ah that was the insight, i had assumed that force
would automagically include the query fragment, but i still needed to return :remote true
in the parser read as well. thanks for your help today!