metasoarous / datsys

(+ clj cljs datomic datascript re-frame-esque-frp)
Eclipse Public License 1.0
231 stars 25 forks source link

Page loading issue #15

Open aquaticrna opened 8 years ago

aquaticrna commented 8 years ago

Bizarre issue where, sometimes, the page won't finish loading until you go back to the source file and save to force figwheel to update the page

metasoarous commented 8 years ago

It seems like manually running lein cljsbuild once sometimes fixes this as well. But would appreciate confirmation from others on this. Hopefully the extraction I'm working on will resolve this issue by properly orchestrating app startup. (I have a feeling this is just a state-dependency issue, where things aren't booting properly). Enter SS Component...

bamarco commented 8 years ago

[UPDATE My bad. There's a difference between the meta on an atom and the db-data inside the atom. Back to the drawing board.]

If you look at view.cljs where posh! gets called in Datview if you add a (log/info "posh-meta" (meta conn)) you'll see listeners. But by the time the go-react loop in reactor.cljc gets called the posh-meta is gone.

So it looks like somewhere in the event loop posh's metadata gets clobbered which is what posh uses to make reactions work for queries.

bamarco commented 8 years ago

@metasoarous Partial fix:

If you replace

(defn type-instance-eids-rx
  [app type-ident]
  (posh/q-tx (:conn app)
             '[[_ :e/type ]]
          '[:find ?e
            :in $ ?type
            :where [?e :e/type ?type]
            ]
          [:db/ident type-ident]
          ))

in dat.sys.client.views.cljs part of the problem will be fixed (css not loading automatically so I'm guessing it gets generated elsewhere with a similar :db/ident query).

This works because posh doesn't handle idents properly when it calls q-gen/q-pattern-gen or possibly when it's doing the pattern matching later. So I just replaced the genpattern with a less restrictive pattern to make sure it gets updated. This will have performance issues if left this way.

metasoarous commented 8 years ago

For the record, we think this is a bug in posh. The updated version @mpdairy is working on should fix this. Crossing fingers...