This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-18
Channels
- # alda (8)
- # aws (1)
- # bangalore-clj (1)
- # beginners (55)
- # boot (114)
- # capetown (2)
- # cljs-dev (51)
- # cljsjs (1)
- # cljsrn (14)
- # clojure (119)
- # clojure-belgium (6)
- # clojure-brasil (9)
- # clojure-conj (2)
- # clojure-greece (1)
- # clojure-korea (2)
- # clojure-poland (12)
- # clojure-russia (64)
- # clojure-spec (12)
- # clojure-uk (60)
- # clojurescript (159)
- # code-reviews (2)
- # component (4)
- # core-matrix (2)
- # cursive (79)
- # datascript (7)
- # datomic (2)
- # defnpodcast (4)
- # events (2)
- # hoplon (13)
- # jobs (2)
- # lein-figwheel (1)
- # off-topic (10)
- # om (42)
- # onyx (60)
- # pedestal (5)
- # perun (7)
- # rdf (4)
- # re-frame (4)
- # reagent (21)
- # ring-swagger (25)
- # schema (1)
- # spacemacs (52)
- # specter (1)
- # utah-clojurians (1)
- # yada (5)
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)
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)
I see from the source the print is expected, the target is added to meta
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
@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.
@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
(om/transact! this `[(user/login {:username user :password pass}) ~(om/force :totals :api)]))
should this force a remote :totals read from the :api remote?I can't get it to work
I don't think that logic is fully wired in
I can't remember
Any other way to force a remote read?
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.@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:
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
however I guess internally om can't track the paths properly? I am not familiar with how the om rendering works.
I often have problems when rendering lists, avoiding those seems to get me on progress for now
(dom/div nil
(dom/div #js {:key "descr"}
description)
(for [file list]
(file-component file)))
Seems to workcool 馃檪
I suppose the lists inside lists could be troublesome somehow.
@bbss: you can always use apply
to splice the list contents in
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).
@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
if you do everything right, the component in a defcard-om-next
will maintain its state upon reload
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 馃檪
@bbss you also need to defonce
the reconciler / parser
Did you ever get that stuff merged into Devcards @anmonteiro ? The devcards-om-next stuff I mean 馃檪
not yet
haven't really touched it in a while
I mean, there's a defcard-om-next
in Devcards currently
it just isn't reload-proof