Fork me on GitHub
#om
<
2015-12-27
>
jimmy03:12:45

hi guys, is there any good example of clojure server for om components ?

Oliver George05:12:15

The om-next-starter has a basic server setup. Not sure if it's best practice. https://github.com/jdubie/om-next-starter

jimmy11:12:04

thanks @olivergeorge it seems to be the closest thing we can get for om next server simple_smile

Oliver George11:12:58

@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.

Oliver George11:12:18

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

anmonteiro12:12:13

@olivergeorge: I think you need to provide read methods for the other keys in the query

sllyq12:12:01

Can anyone tell me what would be good reasons to use or not use datascript in om-next application?

jimmy14:12:35

offline first application would be the best candidate 😄

rhansen14:12:29

or when you are using datomic on the server

johannjohann18:12:44

@sllyq one thing that is handy about datascript is being able to add info to a transaction

johannjohann18:12:34

@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

robert-stuttaford19:12:07

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

robert-stuttaford19:12:01

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

artemyarulin19:12:17

@robert-stuttaford: have you specified send to the reconciler?

artemyarulin19:12:04

hm, hard to say - create a gist, it will be much easier to find an issue

robert-stuttaford19:12:52

are my assumptions correct? it should work under the conditions i think it should?

robert-stuttaford19:12:18

(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})))

robert-stuttaford19:12:38

the prn produces nil for the get call

robert-stuttaford19:12:21

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

johannjohann19:12:18

dont know if this is helpful but this is where the magic would happen

johannjohann19:12:01

i had a gotcha where the remote read wasnt working correctly because i was doing recursive parsing

johannjohann19:12:59

but you can poke around with the parser first and see what it looks like when you do a read with the :remote target

robert-stuttaford19:12:11

yeah. i think i’m going to have to mess around at the repl

robert-stuttaford19:12:15

thanks, appreciate the pointer

johannjohann19:12:58

actually @robert-stuttaford, it doesnt matter if the key is missing or not

robert-stuttaford19:12:19

yeah, i’m realising that. :remote true should be the end of it

johannjohann19:12:29

kk cool didnt want to lead you astray

robert-stuttaford19:12:37

sounds like you’ve already used om.next some, johannjohann. how does it feel?

johannjohann20:12:32

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

robert-stuttaford20:12:50

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

johannjohann20:12:14

yeah whats yr reconciler look like

robert-stuttaford20:12:10

(def reconciler
  (om/reconciler
   {:state     state
    :normalize true
    :parser    parser*
    :send      (util/transit-post "/api")}))

robert-stuttaford20:12:55

i assume it would always post to the endpoint, regardless of a read or a mutate

johannjohann20:12:01

and your root component just has [ :builder/content-list] as a query im assuming?

robert-stuttaford20:12:16

a subcomponent, but yes

robert-stuttaford20:12:39

interesting. i’ve just breakpointed gather-sends and i’m not seeing the query for this component

johannjohann20:12:19

ah i think perhaps you are 'stealing queries'

robert-stuttaford20:12:20

i think i know why. the subc is inside a dynamic routing driven system

robert-stuttaford20:12:30

and so its query is never being considered

johannjohann20:12:52

you can get a repl check

johannjohann20:12:14

by doing om/full-query on your root component i believe

robert-stuttaford20:12:33

yeah. that’s it. the query of the subcomponent isn’t being picked up because it’s being put there dynamically

robert-stuttaford20:12:42

… or not. putting it there statically didn’t help. how does it build the full query up – does it walk the render tree?

johannjohann20:12:57

basically queries need to compose at the root

robert-stuttaford20:12:41

so super components need to explicitly declare sub component queries somehow?

johannjohann20:12:07

ya lemme pull up a nice example for yo

robert-stuttaford20:12:11

actually, i’m out of gas for the day. i’ll try all this again tomorrow when my head’s screwed on right

robert-stuttaford20:12:27

ah, yes, i had forgotten about this example. i’ll study it and try again

Oliver George22:12:33

@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.

jannis23:12:57

@robert-stuttaford: I'd be happy to help if I'm around