Fork me on GitHub
#om
<
2016-11-18
>
denik05:11:07

Did anyone experience a core.cljs:6323Uncaught Error: Invalid arity: 4 exception trying to mount the root component?

(defui App
    static om/IQuery
    (query [_]
      [:app/user])

    Object
    (render [this]
      (dom/pre nil
               (str (om/props this)))))

  (defmulti read om/dispatch)
  (defmethod read :default
    [{:keys [state query] :as env} k _]
    (let [st @state]
      {:value (om/db->tree query (get st k) st)}))

  (def parser {:read read})
  (def reconciler (om/reconciler {:state  {:app/user :foo}
                                  :parser parser}))

  (defcard-om-next AppCard
                   App
                   reconciler)

bbss06:11:06

@denik the parser is not a called by om/parser

danielstockton08:11:27

I discovered the force function from the documentation, to force a remote read after a transaction: https://github.com/omcljs/om/wiki/Documentation-(om.next)#force I can't get it to work as intended, it does trigger a read but there is no target on the AST and if I print (om/force :key :remote) it just gives (quote :key)

danielstockton08:11:57

I see from the source the print is expected, the target is added to meta

bbss09:11:00

I am having trouble figuring what I am doing wrong to cause the No queries exist for component path (speech.core/File) error for this code. https://github.com/bbss/marioide/blob/speech/src/speech/core.cljs#L43

bbss09:11:57

@anmonteiro maybe you can give me a hint? I've exhausted Google for that error and am still not sure what causes it. The parsing works and the props get passed to the component, but somewhere after render it still errors.

anmonteiro09:11:11

@bbss sorry, not enough information and the project is not minimal. I'm happy to look at a minimal case, but I don't have time to go through your whole project

bbss09:11:29

Okay sure

danielstockton09:11:03

(om/transact! this `[(user/login {:username user :password pass}) ~(om/force :totals :api)]))
should this force a remote :totals read from the :api remote?

danielstockton09:11:47

I can't get it to work

anmonteiro10:11:04

I don't think that logic is fully wired in

anmonteiro10:11:20

I can't remember

danielstockton10:11:23

Any other way to force a remote read?

bbss12:11:57

Rewriting it for a minimal case the problem evaporated 馃槃 :thinking_face:

bbss12:11:25

will have to pay close attention to the git diff

bbss12:11:19

I found it, very vicious, still don't understand how the error relates. In one of the components render function:

(let [{:keys [file/list gist/description]} (om/props this)]
            (dom/div nil (for [file list]
                            (file-component file))))
works fine But adding children as vector:
(let [{:keys [file/list gist/description]} (om/props this)]
            (dom/div nil [(dom/div #js {:key "descr"}
                                   description)
                          (for [file list]
                            (file-component file))]))
renders fine.. but gives the no queries exist error.

wilkerlucio12:11:55

@bbss note that on the second example you have a list inside of list, had you tried pulling those as just parts of the dom/div? like:

bbss12:11:55

Yes I can omit the vector and just give them as args

bbss12:11:08

but that way did still render correctly

wilkerlucio12:11:38

it might be an Om bug, but you must remember Om needs to know about all the paths on all components, maybe it's not figuring out lists on lists

bbss12:11:12

however I guess internally om can't track the paths properly? I am not familiar with how the om rendering works.

bbss12:11:22

Yeah that would make sense 馃檪

wilkerlucio12:11:50

I often have problems when rendering lists, avoiding those seems to get me on progress for now

bbss12:11:34

(dom/div nil
                     (dom/div #js {:key "descr"}
                              description)
                     (for [file list]
                       (file-component file)))
Seems to work

anmonteiro12:11:30

I suppose the lists inside lists could be troublesome somehow.

anmonteiro12:11:02

@bbss: you can always use apply to splice the list contents in

denik13:11:02

@bbss ahh! what an oversight. Thanks!

bbss14:11:43

https://anmonteiro.com/2016/01/writing-om-next-reloadable-code-a-checklist/ @anmonteiro in the comments you mention the local state gets blown away, it seems the component gets unmounted entirely no matter what I try. Did you ever find a solution for that? I'm asking because using the lifecycle stuff is nice to have when interacting with non-react dom stuff (like codemirror).

anmonteiro14:11:06

@bbss I don't have time to rethink back to specifics, but I eventually managed to get it working. You can probably find insightful stuff in the commits of this repo: https://github.com/anmonteiro/devcards-om-next

anmonteiro14:11:54

if you do everything right, the component in a defcard-om-next will maintain its state upon reload

bbss14:11:35

Hmm, I am using that, tried all combinations of ^:once on defui and defonce on atoms. Also tried the rerender from root stuff in the comments, using the react key on root method too. I'll try to muck about some more 馃檪

anmonteiro14:11:03

@bbss you also need to defonce the reconciler / parser

bbss14:11:58

Did that too. Must be doing something wrong 馃槃

kauko20:11:26

Did you ever get that stuff merged into Devcards @anmonteiro ? The devcards-om-next stuff I mean 馃檪

anmonteiro20:11:29

haven't really touched it in a while

kauko20:11:06

Alright. I'd probably use it if you did, if that means anything 馃槃

anmonteiro20:11:05

I mean, there's a defcard-om-next in Devcards currently

anmonteiro20:11:11

it just isn't reload-proof