This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-27
Channels
- # admin-announcements (9)
- # aws (1)
- # beginners (4)
- # boot (197)
- # cider (38)
- # cljsrn (70)
- # clojure (128)
- # clojure-russia (36)
- # clojurecup (1)
- # clojurescript (86)
- # core-typed (2)
- # css (1)
- # datomic (35)
- # editors-rus (4)
- # hoplon (22)
- # ldnclj (2)
- # mount (19)
- # off-topic (45)
- # om (63)
- # onyx (7)
- # parinfer (8)
- # yada (2)
The om-next-starter has a basic server setup. Not sure if it's best practice. https://github.com/jdubie/om-next-starter
thanks @olivergeorge it seems to be the closest thing we can get for om next server
@nxqd I wrote simple pull apis for http://asp.net and django last year. I can see how it's not an om.next problem but at the same time it would be nice to have something simple to work from when you want to play.
Vaguely related. Can someone please tell me why my component isn't seeing the remote updates when rerendering. This is a small experiment to read bits of an atom on the server. I used om-next-starter and pruned back.
The component does rerender. The ui's state atom does include the remote data but the component doesn't pick them up via (om/prop this)
.
https://github.com/olivergeorge/stripboard/blob/master/src/om_starter/core.cljs
@olivergeorge: I think you need to provide read methods for the other keys in the query
Can anyone tell me what would be good reasons to use or not use datascript in om-next application?
@sllyq one thing that is handy about datascript is being able to add info to a transaction
@sillyq which might be useful in how you want to handle remote fetching https://github.com/tonsky/datascript/blob/master/test/datascript/test/transact.cljc#L187
has anyone got an om.next app with a backend server up, yet? i find i’m struggling with basics, like how to request data via api on startup. i think i’m doing all the right things, but nothing’s happening
those things: query declares key that’s not present in local state. read parser impl for the key declares :remote true
. but i don’t see the XHR in network
@robert-stuttaford: have you specified send
to the reconciler?
yes. i’ve used https://github.com/jdubie/om-next-starter/blob/master/src/om_starter/core.cljs as a basis
hm, hard to say - create a gist, it will be much easier to find an issue
are my assumptions correct? it should work under the conditions i think it should?
my read impl:
(defmethod read :builder/content-list [{:keys [state] :as env} _ {:keys [remote?]}]
(let [st @state]
(prn 'read :builder/content-list (get st :builder/content-list))
(if-let [v (get st :builder/content-list)]
{:value v :remote true}
{:remote true})))
the prn produces nil
for the get
call
i can put a gist together, but i’m more interested in validating that my understanding is correct: missing key + :remote true == server-side read
dont know if this is helpful but this is where the magic would happen
i had a gotcha where the remote read wasnt working correctly because i was doing recursive parsing
but you can poke around with the parser first and see what it looks like when you do a read with the :remote target
yeah. i think i’m going to have to mess around at the repl
thanks, appreciate the pointer
actually @robert-stuttaford, it doesnt matter if the key is missing or not
yeah, i’m realising that. :remote true
should be the end of it
kk cool didnt want to lead you astray
sounds like you’ve already used om.next some, johannjohann. how does it feel?
ive been thinking about the difference between the ui tree and the data graph--still building intuitions of how to build out stuff but that point has been the coolest so far
ok so (prn (parser* {:state state} [:builder/content-list] :remote))
is producing [:builder/content-list]
, which tells me that something’s off about how my remotes are configured
yeah whats yr reconciler look like
pretty normal:
(def reconciler
(om/reconciler
{:state state
:normalize true
:parser parser*
:send (util/transit-post "/api")}))
i assume it would always post to the endpoint, regardless of a read
or a mutate
and your root component just has [ :builder/content-list] as a query im assuming?
a subcomponent, but yes
interesting. i’ve just breakpointed gather-sends and i’m not seeing the query for this component
ah i think perhaps you are 'stealing queries'
i think i know why. the subc is inside a dynamic routing driven system
and so its query is never being considered
… or something
you can get a repl check
by doing om/full-query on your root component i believe
yeah. that’s it. the query of the subcomponent isn’t being picked up because it’s being put there dynamically
… or not. putting it there statically didn’t help. how does it build the full query up – does it walk the render tree?
basically queries need to compose at the root
so super components need to explicitly declare sub component queries somehow?
ya lemme pull up a nice example for yo
https://github.com/Jannis/om-next-kanban-demo/blob/master/src/kanban/app.cljs#L16
actually, i’m out of gas for the day. i’ll try all this again tomorrow when my head’s screwed on right
ah, yes, i had forgotten about this example. i’ll study it and try again
thanks jj
@anmonteiro: thank you for the suggestion. I tried adding a default reader and it wasn't triggered. I don't think it was required because of db->tree. I'll whittle it down to a simpler test next.
@robert-stuttaford: I'd be happy to help if I'm around