This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-10
Channels
- # admin-announcements (2)
- # arachne (2)
- # beginners (53)
- # boot (52)
- # cider (7)
- # cljs-dev (61)
- # cljsrn (12)
- # clojure (61)
- # clojure-greece (22)
- # clojure-nl (16)
- # clojure-russia (103)
- # clojure-spec (84)
- # clojure-uk (15)
- # clojurescript (137)
- # community-development (14)
- # cursive (4)
- # datomic (14)
- # devcards (6)
- # euroclojure (3)
- # funcool (26)
- # hoplon (27)
- # jobs (4)
- # lambdaisland (1)
- # leiningen (1)
- # om (75)
- # onyx (77)
- # planck (15)
- # proton (2)
- # re-frame (23)
- # ring-swagger (9)
- # schema (1)
- # specter (95)
- # untangled (124)
- # yada (27)
@fasiha: Sure. What else do you want to know? No, not storing my connection inside the app-db. I never put anything but data in my app-db or datascript db so it can be serialized to disk or over the network. Why not just access the conn from outside the subscription?
@roberto: I found a much easier lifecycle library called mount
. Doesn’t require a major re-architecture of the app and you get many of the benefits from component:
;; create the datascript database
(defstate shared-db
:start (let [conn (init-ds-db! :shared-db config/shared-schema config/shared-storage-key)]
(d/listen! conn :shared-lunr-updates listen-update-lunr-index!)
conn)
:stop (do (ds->async-storage @shared-db config/app-storage-key)
(d/unlisten! @shared-db :shared-lunr-updates)
nil))
https://github.com/tolitius/mount/I'm not a fan of mount. Used it in a project and I regret it. But if it works for you, rock on.
@seantempesta: nice, gotcha! I've used mount to handle backend services (nrepl, http-kit, DataScript on the backend), but never thought about using it in the front end. What namespace did you put that shared-db
state in? In db.cljs?
While I was describing my stupid way of handling subscriptions into app-db to retrieve the Datascript conn, I realized I was doing it foolishly and reorganized it, but I can see that it's unwise to keep an atom to a Datascript db in app-db. Putting it in mount state sounds interesting enough to try
the things I don’t like about mount is that there is not an obvious way to know what are your dependencies. With component, there is one place you can get an overview of how the app is architected.
@fasiha: I made a separate datascript namespace
Some great re-frame discussion going on in this thread: https://github.com/Day8/re-frame/issues/170
Hi all - I'm a beginner with both ClojureScript and re-frame - I've a (basic) question posted here - http://stackoverflow.com/questions/37751108/re-frame-subscription-not-working-as-expected - any / all help much appreciated....
@roberto: reason for that is debugging - described here: https://github.com/Day8/re-frame/wiki/Debugging#your-project
...though even with clairvoyant and re-frame-tracer (which make things much clearer - brilliant) I'm still stumped!
I'm fairly sure votes
is populated but cv
is not ... if I edit cvs-sub-reaction
and replace (get-vote-by-id votes cv)
with (get-vote-by-id votes 2)
(for example) it's evaluating to a vector containing a single map, which is the desired result (except it's just always the one with the id I hard-code). :current-vote
is a number which should match the :id
of the map selected from :votes
I'm using :current-vote
in my app-db as a reference to a specific item in :votes
(let [cv (get-in @db [:current-vote])
votes (get-in @db [:votes])]
(get-vote-by-id votes (:id cv)))
Thanks @roberto - but I'm not sure that's it (gave it a try though... appreciated). Above screenshot shows that get-vote-by-id
is passed an integer, it's just that it's evaluating to []
... but when I invoke get-vote-by-id
directly (from repl) with same values, it works... utter confusion.
Just realised I contradicted my earlier comment - cv
is evaluating to a number (sorry), and votes
is an array.. it's the evaluation of get-vote-by-id
that causes the confusion.