Fork me on GitHub

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


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


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


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


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


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


I tried to create a dummy simulated response of a remote server based on simulated server from, 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


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


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


@fifigyuri: your response looks fine to me


@fifigyuri: normally server responses dont arrive normalized


Om will normalize them for you when you call cb


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


Depends whether you're communicating to elasticsearch directly


Or if your endpoint is communicating with elasticsearch


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


Right, but still, depending on the response format


Perhaps Om can normalize it according to the query?


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


Do you do normalization?


I don’t see anything wrong then


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


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


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 😞


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


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


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


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


You need to let know what to update after a mutation


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

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


Thanks, it works:+1:


@anmonteiro: I have a question regarding gather-sends when we change route. I have created the minimal case here: 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 : I'm pretty stuck 😞


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


you should either return true or an AST for remote calls


e.g. {:remote true}


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


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


I usually clone om & run my own version of it


That way you have complete control to extend it for debugging


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