Fork me on GitHub

i’m a little confused about how IDidUpdate works


my most basic understanding is that it’s called whenever the component state or app state changes


but i’m not sure why it’s called twice when i make a single change with om/set-state


@krchia: Your understanding sounds correct to me. It should be called just after render and after the DOM is updated. Are you maybe calling set-state! from inside did-update, triggering it a second time?

Yehonathan Sharvit13:08:10

Can somebody help me to understand why does Om Next component not re-render when state changes?


@viebel: that SO example will never re-render because the queries are not composed correctly


maybe you’re having a similar problem with your query structure?

Yehonathan Sharvit14:08:36

@anmonteiro: Two questions: 1. What is not correct in the query composition 2. If it’s not correct, why does it work when updating the state from the REPL


@viebel: so the components have queries like:

(defui Child
  static om/IQuery
  (query [this]

(defui Parent
  static om/IQuery
  (query [this]


when you add-root!, you call that with the Parent component


but there’s no composition in the queries, so Om Next can’t know that there’s a child component somewhere


the correct composition would be something like this for the parent’s query:

[:parent {:child (om/get-query Child)}]


state updates because you’re using normal constructs like swap!. But for Om Next there exists no components below the Root, so it doesn’t know that it has to update

Yehonathan Sharvit14:08:54

In my case, I have query composition. Render is called on user event but is not called when I am updating the state without any user event (I am triggering a state update every 3 seconds)


@viebel: do you have a link to the example or can put a minimal case together?


multiple things might be going on so I can’t give a clear answer

Yehonathan Sharvit14:08:32

I want to trigger code evaluation if the user press Ctrl-Enter and after 3 seconds of inactivity

Yehonathan Sharvit14:08:49

The 1st one works fine. The second one is broken (it used to work)


@viebel: right, where is the actual code that updates the state?


@viebel: A number of things might be happening, the example it just too conflated


esp. with the core.async bits


I suggest you make a minimal case I could look at


I don’t have time to grok everything this code is doing

Yehonathan Sharvit14:08:27

Thanks for your time


Can I return two queries from a read function to a remote? I tried an AST with type :root and two children, but then my send function get a query like [[q1 q2]] which is one vector to much.


@akiel: I think you'll need to override merge-sends in the reconciler


But normally one is supposed to return only an AST fragment not a root AST? (as the docu says)


I can't recall what the documentation says, but the existent hooks in the reconciler allow you to extend the defaults


So I'd say either is correct


The docu says: Remote query entries must be query expression AST fragments that correspond to the :remotes specified to the reconciler.


@anmonteiro: As I see it, merge-sends doesn’t solve my problem. But thanks nevertheless.