Clojurians
#om
<
2016-08-02
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

krchia02:08:51

i’m a little confused about how IDidUpdate works

krchia02:08:17

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

krchia02:08:27

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

peeja13:08:36

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

viebel13:08:10

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

anmonteiro14:08:37

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

anmonteiro14:08:49

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

viebel14:08:19

Let me check

viebel14: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

anmonteiro14:08:54

@viebel: so the components have queries like:

(defui Child
  static om/IQuery
  (query [this]
    [:foo]))

(defui Parent
  static om/IQuery
  (query [this]
    [:parent]))

anmonteiro14:08:10

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

anmonteiro14:08:39

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

anmonteiro14:08:08

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

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

anmonteiro14:08:24

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

viebel14: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)

viebel14:08:00

Is it clear?

anmonteiro14:08:00

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

anmonteiro14:08:18

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

viebel14:08:32

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

viebel14:08:49

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

anmonteiro14:08:19

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

anmonteiro14:08:36

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

anmonteiro14:08:46

esp. with the core.async bits

anmonteiro14:08:02

I suggest you make a minimal case I could look at

anmonteiro14:08:11

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

viebel14:08:20

I understand.

viebel14:08:27

Thanks for your time

akiel18:08:09

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.

anmonteiro18:08:24

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

akiel18:08:21

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

anmonteiro18:08:52

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

anmonteiro18:08:18

So I'd say either is correct

akiel18:08:21

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

akiel19:08:26

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