Fork me on GitHub
#om
<
2016-04-18
>
fifigyuri01:04:59

Hi, how can I initiate the state of a component with om-next? Implementation of IInitState used set the state, now it does not work for me

isak02:04:53

@fifigyuri: use (initLocalState [_] ...)

grounded_sage06:04:11

@anmonteiro: is it safe to use cellophone? Is it planned to be merged into Om at some stage? I'm currently looking at learning Om Next (first UI library, I'm also very new to programming). Was looking at basically building a client side only website (static site) that uses Om Next for interactivity. I know there is more simple and easy options out there but I am looking to incrementally work towards grokking Om Next. I'm also interested in the Om-css library you created and it's status. The cascade is a killer sometimes.

fifigyuri07:04:02

@isak, thank you, I see sometimes the best resource to check for om-next now is to go to the source codes

anmonteiro10:04:39

@grounded_sage: it's somewhat planned to be merged, no concrete predictions though

anmonteiro10:04:28

It's safe to use it, I suppose, Ladder is using it and so far so good. Same for om-css

fifigyuri10:04:41

I tried to create a dummy simulated response of a remote server based on simulated server from https://github.com/awkay/om-tutorial/blob/master/src/main/om_tutorial/client_remoting.cljs#L17, but I do not know what the server response should look like, seems like it’s not a simple database. My send code looks like that now

fifigyuri10:04:49

(defn send [{:keys [remote]} cb]
  (let [_ (println "Payload: " remote)
        {:keys [query rewrite]} (om/process-roots remote)
        _ (println "server query: " query)
        server-response {:articles {1 {:id 1 :title "Foo" :summary "Bar"}}}]
    (js/setTimeout (fn []
                     (println "state to merge " (rewrite server-response))
                     (cb (rewrite server-response))
                     ) 1000)))

fifigyuri11:04:03

can you give me a hint what the server-response should look like? First I want to understand that, after I could make a real communication with elasticsearch

mitchelkuijpers11:04:42

@fifigyuri: your response looks fine to me

anmonteiro11:04:01

@fifigyuri: normally server responses dont arrive normalized

anmonteiro11:04:28

Om will normalize them for you when you call cb

fifigyuri11:04:00

I will need to make some normalization I think for the response from elasticsearch, I guess only datomic plays nice with om regarding the response

anmonteiro11:04:44

Depends whether you're communicating to elasticsearch directly

anmonteiro11:04:59

Or if your endpoint is communicating with elasticsearch

fifigyuri11:04:58

directly, having an app-server for my application would add an unnecessary extra layer

anmonteiro11:04:34

Right, but still, depending on the response format

anmonteiro11:04:50

Perhaps Om can normalize it according to the query?

fifigyuri11:04:25

@mitchelkuijpers: than it seems the problem is somewhere else, not in the response form, maybe only the state changes are not queued for rerendering

mitchelkuijpers11:04:43

Do you do normalization?

mitchelkuijpers11:04:32

I don’t see anything wrong then

mitchelkuijpers11:04:11

Sorry just read the part above, lol you already said you don’t use normalization.

leontalbot12:04:25

@madvas really cool todo app! Out of curiosity, is it datomic free or pro and where did you host it? Thanks!

jimmy12:04:19

I wonder what is the best way to read things as root instead of reading things recursively through another level like : dom-com/props ? I find that doing things recursively is quite troublesome especially when we have parameterized join query 😞

madvas12:04:54

@leontalbot: thanks! It’s datomic free, it’s on heroku, it works out of the box! but DB is reset with every heroku spin up, so it’s suitable only for example apps I guess 😄

jimmy12:04:52

@fifigyuri: in order to gain the benefit of om next, you would enable normalize. It's best you need to know how to produce a good format from elastic then om next will normalize the results for you. ( Check function default-merge-tree in next.cljs )

leontalbot12:04:01

@madvas thanks! I was wondering what is the cheapest way to host datomic...

madvas12:04:36

@leontalbot: Actually, I’d be interested that answer as well 😄

mitchelkuijpers15:04:09

You need to let om.next know what to update after a mutation

mitchelkuijpers15:04:16

So in your case you need to change the call to transact!

(om/transact! this `[(core/inc-value)])
to
(om/transact! this `[(core/inc-value) :mail])

anton_k15:04:55

Thanks, it works:+1:

jimmy17:04:06

@anmonteiro: I have a question regarding gather-sends when we change route. I have created the minimal case here: https://github.com/rhacker/om/commit/d6dcada3155c356995767c5818d338f62eb868de When we change route by click on the button in this case, I expect that the remote should be sent but there is none because the remote is empty. I have debugged to understand the problem but it seems like the remote send will always be empty [] if I do the remote collecting through :dom/props like in the code above because the (parser ..) returned in the :com/props case will be a vector, and these lines don't seem to allow it : https://github.com/omcljs/om/blob/master/src/main/om/next/impl/parser.cljc#L262-L263. I'm pretty stuck 😞

anmonteiro19:04:49

the send function is not being called because you’re not returning a valid thing in your parser

anmonteiro19:04:21

you should either return true or an AST for remote calls

anmonteiro19:04:30

e.g. {:remote true}

anmonteiro19:04:04

you’re returning a vector (the result of recursively calling the parser) which is not valid

fifigyuri19:04:27

I returned to the issue with the not updating of the component after send, I checked and the state was updated correctly, but for some reason the updates are not queued to be re-rendered. The queues on the defui seems to be correct. Is there a way to put queries to the re-rendering queue manually? I want to try that only for debugging purposes

iwankaramazow19:04:17

I usually clone om & run my own version of it

iwankaramazow19:04:58

That way you have complete control to extend it for debugging

fifigyuri19:04:34

thanks, that’s a hint how to understand also om internals