Zetawar / zetawar

Zetawar is a turn based tactical strategy game implemented in 100% ClojureScript.
MIT License
169 stars 14 forks source link

Posh vs Deftrack'd q #32

Closed Conaws closed 7 years ago

Conaws commented 7 years ago

The current version of posh/q doesn't totally match up against datascript/q. Particularly, it doesn't allow you to use pull inside a query.

I'm curious, could you use Deftrack to write a small wrapper around datascript's q, and get essentially the same functionality as posh -- or is posh's caching or updating much more sophisticated than what r/track would provide?

Could you wrap d/entity with r/track and use entities in the UI, or would that be inefficient.

djwhitt commented 7 years ago

Interesting suggestion. Unfortunately, performance would suffer if you took posh completely out of the picture. Caching would be the same, but the tracks would rerun whenever the data changed rather than just when relevant data changed.

While it's not a universal solution, a reasonable workaround for the lack of pull syntax in posh queries is to create separate reactions (deftracks in my case) for the eid queries and pulls:

https://github.com/Zetawar/zetawar/blob/master/src/clj/zetawar/subs.cljs#L41 https://github.com/Zetawar/zetawar/blob/master/src/clj/zetawar/subs.cljs#L47