Fork me on GitHub
#om
<
2016-05-20
>
jbranchaud00:05:26

Some combination of the latest google chrome, om.next, and/or figwheel do not seem to be working together. When I work through the first part of the Om.Next tutorial and try to load up localhost:3449, I get the exceed max line 4096 error. Is anyone else experiencing this?

graemenelson00:05:30

@jbranchaud: I just went through the tutorial yesterday without a hitch. I am using Chrome Mac Version 50.0.2661.86. I used the om.next/figwheel/etc defined in the project.clj file

graemenelson00:05:05

I did wrap the lein call in rlwrap

graemenelson00:05:48

And just to be a little bit more verbose 😉 lein —version gives me: Leiningen 2.5.3 on Java 1.8.0_91 Java HotSpot(TM) 64-Bit Server VM

jbranchaud00:05:42

hmm, so I just got it to work with an incognito window. Any ideas what could be going on in a regular chrome window that would cause this?

graemenelson00:05:03

I don’t sorry, I am just starting out myself 😉

jbranchaud00:05:14

Thanks for replying. I have something to work with now!

danburton01:05:13

Something to do with large cookies, perhaps? https://github.com/http-kit/http-kit/issues/196

jbranchaud01:05:03

@danburton brilliant. I went in and deleted some localhost cookies that should have been cleared out long ago and everything works as expected now. Thanks!

danburton01:05:25

Looks like a bug with http-kit, which is used by figwheel-sidecar, which presumably you are using for the om.next demo.

petterik15:05:09

@anmonteiro: I've created the smallest repro I could do of what seems like a build-index* bug, where eventually a call on nil is happens in clojure.zip/node. Setup involves queries which depend on props, where nested components call om/set-query!. Link: https://github.com/petterik/om/tree/zip-node-nil-error

tomjack15:05:28

(let [component (get-in (om/props this) route-path)] (conj query {:route/data (om/get-query component)}))

tomjack15:05:38

This confuses me

tomjack15:05:51

Does (om/get-query component) maybe return nil there?

petterik15:05:24

Yeah, it's confusing. I added an assert and it doesn't return nil. It's returning a component's route (which is a component). Check the state for the commit

petterik15:05:52

I added an assert to be certain that it's not nil. The devcard is runnable, if you're interested in checking it out

petterik15:05:53

edit: the state for the reconciler*

tomjack15:05:01

Oh, I see. I looked at the state but still did not see it :)

petterik15:05:58

It's not straight forward code, but I just wanted to hit this corner case 🙂

anmonteiro16:05:22

@petterik: looking into it now

ag18:05:10

is it possible to dispatch on more than one key? e.g.

(defmethod read [:foo/bar :foo/baz] 
     [_ key _]
       (if (= key :foo/bar) …etc..)))

tomjack18:05:55

Technically you could use a custom hierarchy? Not sure I'd recommend it..

tomjack18:05:01

I am not sure if -add-method is supposed to be private, but it can also be handy

tomjack18:05:42

Not sure if it's clear to you: note that your question is about multimethods, not om, and you can define read/mutate however you like

ag18:05:26

@tomjack: I’m gonna pretend that you’re talking about quantum physics and that whatever you said totally made sense to me and I would keep nodding and just say nothing 😄

tomjack19:05:03

What doesn't make sense? I would not recommend a custom hierarchy partly because it's not well known :)

tomjack19:05:47

Also you would have to write just one of the keys and the others would be magically dispatched there based on the hierarchy

tomjack19:05:42

I guess the short answer is: no

cmcfarlen19:05:34

I'm having an issue when I'm creating a remote entity on the server, but also adding novelty by adding attributes during the create (adding a sequence number). So I'm returning a stable id, but also adding novelty to the new entity. I think the problem is in the order of operations of merge!

cmcfarlen19:05:12

So I'm merging:

{app/create-circuit {:tempids {[:db/id <#C06DT2YSY>/id["7c2ee779-f632-4359-9115-8e8aaac7d2dd"]] [:db/id 17592186045857]}}, [:db/id 17592186045857] {:circuit/id 12}}

cmcfarlen19:05:40

But since merge! add novelty before resolving tempids, I have to include the tempid in the novelty

cmcfarlen19:05:15

But then the reconciler can't update the component because its trying to look it up by tempid. So I end up having to send the novelty by both tempid and stable id

cmcfarlen19:05:18

{app/create-circuit {:tempids {[:db/id <#C06DT2YSY>/id["7c2ee779-f632-4359-9115-8e8aaac7d2dd"]] [:db/id 17592186045857]}}, [:db/id <#C06DT2YSY>/id["7c2ee779-f632-4359-9115-8e8aaac7d2dd"]] {:circuit/id 12}, [:db/id 17592186045857] {:circuit/id 12}}

jasonjckn20:05:17

db->tree did a double ident following automatically, nice!

jasonjckn20:05:35

(def state (atom {:todo/by-id {1 {:todo/id 1 :todo/title "got milk?"}
                               2 {:todo/id 2 :todo/title "bar"}}

                  :todo-list/by-id {1 [[:todo/by-id 1]
                                       [:todo/by-id 2]]}

                  :widget/root {:todo/list [:todo-list/by-id 1]}}))

jasonjckn20:05:50

query expr: [{:widget/root [{:todo/list [:todo/title :todo/id]}]}]

jasonjckn20:05:21

it seems to only work it's magic on singletons

jasonjckn20:05:33

(def state (atom {:todo/by-id {1 {:todo/id 1 :todo/title "got milk?"}
                               2 {:todo/id 2 :todo/title "bar"}
                               3 {:todo/id 3 :todo/title "bazz"}
                               }

                  :todo-list/by-id {1 [[:todo/by-id 1]
                                       [:todo/by-id 2]]
                                    2 [[:todo/by-id 3]]}

                  :widget/root {:todo/list [[:todo-list/by-id 1]
                                            [:todo-list/by-id 2]
                                            ]}}))
gives me back the data
{:todo/list
 [[{:todo/title "got milk?", :todo/id 1}
   {:todo/title "bar", :todo/id 2}] 
  [{:todo/title "bazz", :todo/id 3}]]}
which is still decent attempt at resolving the query expression, but I don't think htat piece of data corresponds to the query expression
[{:widget/root [{:todo/list [:todo/title :todo/id]}]}]

jasonjckn20:05:03

if I don't specify :keys on a mutation, what are the consequences? does :keys just take root keys only?, or a query expression? or? what happens if I mutate an ident, do I need to return the keys of the ident that changed, as well as any keys that may have subtrees that reference this ident?

cmcfarlen21:05:07

@jasonjckn: can you give an example?

jasonjckn21:05:32

sure,

(def state (atom {:todo/by-id {1 {:todo/id 1 :todo/title "got milk?"}
                               2 {:todo/id 2 :todo/title "bar"}}

                  :todo-list/by-id {1 [[:todo/by-id 1]
                                       [:todo/by-id 2]]}

                  :widget/root {:todo/list [:todo-list/by-id 1]}}))
(defmethod mutate 'todo/add! [{:keys [state target]} key {:keys [title]}] {:action (fn [] (swap! state (fn [{:keys [todo/by-id todo/list] :as st}] (let [id (next-id by-id)] (-> st (update :todo/by-id assoc id {:todo/id id :todo/title title}) (update-in [:todo-list/by-id 1] conj [:todo/by-id id]))))))}) ` what do I return for {:keys ...} in the mutation

jasonjckn21:05:08

at the end of the day I have no mental model for {:keys } what does om.next do withit?

jasonjckn21:05:18

right now I don't have any :keys specified and haven't had any issues yet

jasonjckn21:05:51

the docs say something about identifying what's changed in :keys

jasonjckn21:05:13

i don't even know if it takes query expressions, or just a vector of root keys that have changed, or

jasonjckn21:05:30

in this example

:widget/root
has 'changed' due to ident following, so are the keys for this mutation
[:widget/root :todo/by-id :todo-list/by-id]

cmcfarlen21:05:46

@jasonjckn: oh, :keys here is just the 3rd argument destructuring to bind the value of the :title key to title

cmcfarlen21:05:15

When you call (om/transact! this '[(todo/add {:title "blah"})]) om calls your parser with {:title "blah"} as the third parameter which your mutate fn destructures with that syntax.

danburton21:05:48

I think he is talking about the :keys portion of the returned map.

danburton21:05:55

(Which is currently absent)

cmcfarlen21:05:45

oh, I see... ha

danburton22:05:38

I really want to know the answer now, but my google-fu has not come up with anything satisfactory...

danburton22:05:52

My intuition says it should be [[:todo/by-id id] [:todo-list/by-id 1]]

danburton22:05:12

I don't even know if that's valid though.

jasonjckn22:05:05

i'm getting the error

next.cljs:1268 Uncaught #error {:message "No queries exist for component path (om-todomvc.core/RootView om-todomvc.core/MainView om-todomvc.core/TodoList om-todomvc.core/TodoItem) or data path [:widget/root :widget/main [:todo-list/by-id 1]]", :data {:type :om.next/no-queries}}
when I double click on one of the TODO items, the error makes no sense to me, i don't know what code is relevant, here's the whole source code https://www.refheap.com/4a23101ec4a22da858a1d23f4#L-73 if you look at L73, if I replace that with update-state with a blank #() then the error stops happening, not sure why update-state would produce an error message like that

jasonjckn22:05:44

@danburton: thanks, do you know if :keys are needed before both local and remote mutations, or just remote?

danburton22:05:32

I don't know, I only have a little experience with om.next

cmcfarlen23:05:55

@jasonjckn: I looked into your question a bit out of curiosity, but didn't see where the :keys were used. The parser code mentions being able to return {:value {:keys [...]}} from a mutate fn, but it wasn't obvious where that was used in the reconciler.

cmcfarlen23:05:42

I'm curious about this now too and wonder if it is supposed to solve a problem I've been seeing with updating dependent components. I think its experiment time!